Giter Club home page Giter Club logo

Comments (18)

rjoshig avatar rjoshig commented on May 10, 2024 14

Changed matplotlibrc to below:-

echo "backend: Agg" > ~/.config/matplotlib/matplotlibrc

Now it doesn't throw an error but it does not display anything either. What am i missing here?


 catalyst run -f buy_and_hodl.py --start 2015-3-2 --end 2017-7-31 --capital-base 100000 -o bah.pickle

[2017-10-14 21:25:23.349705] INFO: run_algo: running algo in backtest mode
[2017-10-14 21:25:23.499095] INFO: Loader: Loading benchmark data for 'USDT_BTC' from 2015-03-02 00:00:00+00:00 to 2017-10-03 00:00:00
[2017-10-14 21:25:27.163971] INFO: Performance: Simulated 883 trading days out of 883.
[2017-10-14 21:25:27.164118] INFO: Performance: first open: 2015-03-02 00:00:00+00:00
[2017-10-14 21:25:27.164282] INFO: Performance: last close: 2017-07-31 23:59:00+00:00

from catalyst.

balee323 avatar balee323 commented on May 10, 2024 5

I ran into the same issue and set this in my code.

import Tkinter
import sys
import os

if os.environ.get('DISPLAY','') == '':
    print('no display found. Using :0.0')
    os.environ.__setitem__('DISPLAY', ':0.0')


#create main window
master = Tkinter.Tk()
master.title("tester")
master.geometry("300x100")


#make a label for the window
label1 = Tkinter.Label(master, text='Hellooooo')
# Lay out label
label1.pack()

# Run forever!
master.mainloop()

from catalyst.

jasvinderchhabra avatar jasvinderchhabra commented on May 10, 2024 2

After setting

if os.environ.get('DISPLAY','') == '':
print('no display found. Using :0.0')
os.environ.setitem('DISPLAY', ':0.0')

I am getting below issue.

window=tkinter.Tk()
File "/usr/lib64/python3.6/tkinter/init.py", line 2023, in init
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display ":0.0"

Can anyone help please I am running code in Linux

from catalyst.

srishkee avatar srishkee commented on May 10, 2024 1

I ran into the same issue and set this in my code.

import Tkinter
import sys
import os

if os.environ.get('DISPLAY','') == '':
    print('no display found. Using :0.0')
    os.environ.__setitem__('DISPLAY', ':0.0')


#create main window
master = Tkinter.Tk()
master.title("tester")
master.geometry("300x100")


#make a label for the window
label1 = Tkinter.Label(master, text='Hellooooo')
# Lay out label
label1.pack()

# Run forever!
master.mainloop()

Thank you so much for posting this - worked for me! I downloaded Xming and set the display using the os.environ setitem() function and Xming was able to display my Tkinter application.

from catalyst.

hacktek avatar hacktek commented on May 10, 2024

Same issue in Ubuntu.

(catalyst-venv) root@ovh:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial

(catalyst-venv) root@ovh:~# catalyst run -f buy_and_hodl.py --start 2015-3-2 --end 2017-6-28 --capital-base 100000 -o bah.pickle
[2017-10-18 04:34:56.553822] INFO: run_algo: running algo in backtest mode
[2017-10-18 04:34:56.705316] INFO: Loader: Loading benchmark data for 'USDT_BTC' from 2015-03-02 00:00:00+00:00 to 2017-10-03 00:00:00
[2017-10-18 04:35:01.258081] INFO: Performance: Simulated 850 trading days out of 850.
[2017-10-18 04:35:01.259023] INFO: Performance: first open: 2015-03-02 00:00:00+00:00
[2017-10-18 04:35:01.259226] INFO: Performance: last close: 2017-06-28 23:59:00+00:00
Traceback (most recent call last):
File "/root/catalyst-venv/bin/catalyst", line 11, in
sys.exit(main())
File "/root/catalyst-venv/local/lib/python2.7/site-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/root/catalyst-venv/local/lib/python2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/root/catalyst-venv/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/root/catalyst-venv/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/root/catalyst-venv/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/root/catalyst-venv/local/lib/python2.7/site-packages/catalyst/main.py", line 98, in _
return f(*args, **kwargs)
File "/root/catalyst-venv/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/root/catalyst-venv/local/lib/python2.7/site-packages/catalyst/main.py", line 294, in run
live_graph=live_graph
File "/root/catalyst-venv/local/lib/python2.7/site-packages/catalyst/utils/run_algo.py", line 362, in _run
overwrite_sim_params=False,
File "/root/catalyst-venv/local/lib/python2.7/site-packages/catalyst/algorithm.py", line 749, in run
self.analyze(daily_stats)
File "/root/catalyst-venv/local/lib/python2.7/site-packages/catalyst/algorithm.py", line 490, in analyze
self._analyze(self, perf)
File "buy_and_hodl.py", line 83, in analyze
ax1 = plt.subplot(611)
File "/root/catalyst-venv/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 1052, in subplot
fig = gcf()
File "/root/catalyst-venv/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 588, in gcf
return figure()
File "/root/catalyst-venv/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 534, in figure
**kwargs)
File "/root/catalyst-venv/local/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 170, in new_figure_manager
return cls.new_figure_manager_given_figure(num, fig)
File "/root/catalyst-venv/local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 1049, in new_figure_manager_given_figure
window = Tk.Tk(className="matplotlib")
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1818, in init
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

from catalyst.

lacabra avatar lacabra commented on May 10, 2024

Can either one of you confirm that you are running these commands in a local machine, vs ssh'ing remotely to another machine. If that's the case, this problem is covered elsewhere, for example: here

Alternatively, if you don't have a display, you can run matplotlib without an interactive display by saving plots to files for example, as explained here

Found this other relevant suggestion:
export DISPLAY=0.0; xhost +
from this post

Let me know if any of the above resolve your issue.

from catalyst.

lacabra avatar lacabra commented on May 10, 2024

One clarification note. Catalyst doesn't need matplotlib to run, it needs matplotlib to display summary/performance charts if you so choose.
You can comment out all the code in the def analyze() function in your algo, and just specify an output file with the -o flag in the command line. You can then use other software to analyze the results, such as pyfolio.

from catalyst.

rjoshig avatar rjoshig commented on May 10, 2024

I am using Windows Subsystem for Linux and logged in via ssh using Putty. I tried the ssh -X option . Still not working. Thanks for taking time to help us. I will try and figure out this display thing.

Question

  1. So I run this in command line with -o option

catalyst run -f buy_and_hodl.py --start 2017-3-2 --end 2017-7-31 --capital-base 100000 -o bah.pickle
2. Then I started jupyter
jupyter notebook

  1. I can see that .ipynb are generated.
    -rw-rw-r-- 1 ethdev ethdev 195688 Oct 19 19:29 Untitled.ipynb

  2. Is this file generated ? Can i specify the filename? if yes how?

  3. What exactly is bah.pickle in the command above? Is this the output of the run.

  4. Bascically how do i generate the ipynb file using the run.

from catalyst.

lacabra avatar lacabra commented on May 10, 2024

Closing this issue, since it's not specific to catalyst, but to the specific running environment and matplotlib. See my first post above for alternative setups.

@mesnia, please open different issues to report different problems, otherwise it's hard to keep track of them. But answering your question on number 3, inside jupyter notebook, go to File -> Rename. This will rename the current notebook, and use that for the filename to save it on disk.

the pickle is the output of the catalyst simulation that contains the performance data of your algorithm. The .ipynb is a copy of the jupyter network that you just created, which is the list of commands you have run, and the results from running these commands, so they are two very different files.

from catalyst.

mautc12 avatar mautc12 commented on May 10, 2024

I have coding:
#import matplotlib
#matplotlib.use('Agg')
import matplotlib.pyplot as plt
#print ('Hello, how are you now')
import numpy as np
import matplotlib.pyplot as plt
n = 1000
X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
C,S = np.cos(X), np.sin(X)
plt.plot(X, C)
plt.plot(X,S)
plt.show()
When I am running the above example in the server through the laptop windows connected to the server's ubuntu, the following error appears:
image
Please help me? I followed this link: https://stackoverflow.com/questions/37604289/tkinter-tclerror-no-display-name-and-no-display-environment-variable
but failed
thank you!
I

from catalyst.

nikithashr avatar nikithashr commented on May 10, 2024

Hi, could anyone find a fix for @mautc12 's problem

from catalyst.

lacabra avatar lacabra commented on May 10, 2024

As posted above, this issue is unrelated to Catalyst, and there are many different configurations that can cause and resolve this issue. First of all, we don't have enough information about @mautc12's environment to resolve this issue. Some possible troublehsooting that you would need to figure out before attempting to display any Catalyst output would be:

  • Do you have an Xserver/GUI environment installed on the Ubuntu server? Some server configurations don't have a display enabled by default because they are only meant to be SSH'ed into, and omit all those packages to save harddrive space, but you need to install some to make this work properly.
  • Does the SSH server in Ubuntu support SSH tunneling, and are you SSH'ing into that machine with tunneling enabled?
  • If your client is Windows, you will need an instance of an Xserver installed and configured to display the remote windows locally. In Linux that comes by default, in Mac you need something like XQuartz, and in Windows something like Cygwin.

Once you have all of the above pieces installed, and working, you may need to tweak their configuration and test them using something as simple as opening an instance of xterm remotely and have it appear in your local environment. Once you have that, you can start tackling the Catalyst-specific errors, so as you can see this is mostly unrelated to Catalyst.

from catalyst.

wentianl20 avatar wentianl20 commented on May 10, 2024

@lacabra 's answer should solve this issue. You need a XQuartz or similar software on client and configure your server config with X11 Forwarding yes something.

from catalyst.

rameshwarmore555 avatar rameshwarmore555 commented on May 10, 2024

@mautc12 i am also having the same issue can tou help me with that? thanks in advance

from catalyst.

kaibawong avatar kaibawong commented on May 10, 2024

Hi, I am running python via binder and would like to run a GUI code. Having done
from tkinter import *

I get the following error: (I am not sure what is wrong.. is it saying I dont have the correct environment?) Please help!

TclError Traceback (most recent call last)
in
21
22 # tkinter GUI
---> 23 root= tk.Tk()
24
25 canvas1 = tk.Canvas(root, width = 1200, height = 450)

/srv/conda/envs/notebook/lib/python3.7/tkinter/init.py in init(self, screenName, baseName, className, useTk, sync, use)
2021 baseName = baseName + ext
2022 interactive = 0
-> 2023 self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
2024 if useTk:
2025 self._loadtk()

TclError: no display name and no $DISPLAY environment variable

from catalyst.

gzpmanish avatar gzpmanish commented on May 10, 2024

If we used a windows OS then we need to install Xming server.
Try to connect putty and change the setting of putty is ssh>x11>enable X11 forwarding

from catalyst.

jasvinderchhabra avatar jasvinderchhabra commented on May 10, 2024

After setting

if os.environ.get('DISPLAY','') == '':
print('no display found. Using :0.0')
os.environ.setitem('DISPLAY', ':0.0')

I am getting below issue.

window=tkinter.Tk()
File "/usr/lib64/python3.6/tkinter/init.py", line 2023, in init
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display ":0.0"

Can anyone help please I am running code in Linux

from catalyst.

mautc12 avatar mautc12 commented on May 10, 2024

from catalyst.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.