Python Forum
Colab, Github, starts - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Colab, Github, starts (/thread-31800.html)



Colab, Github, starts - yeeping50 - Jan-04-2021

Hi, I am very new to Python. When I try to run the below code in Colab, got the below error message. How to start with? Anybody?

! git clone https://github.com/llSourcell/Q-Learning-for-Trading.git

Cloning into 'Q-Learning-for-Trading'...
remote: Enumerating objects: 25, done.
remote: Total 25 (delta 0), reused 0 (delta 0), pack-reused 25
Unpacking objects: 100% (25/25), done.

run.py

NameError Traceback (most recent call last)
<ipython-input-2-75e852f83f6c> in <module>()
----> 1 run.py

NameError: name 'run' is not defined


RE: Colab, Github, starts - yeeping50 - Jan-05-2021

Dear All experts,

Already got some improvement since my 1st post. But stuck here can't move forward. Any one can pick up from here? Appreciated a lot. The code from Colab will be look like this.

! git clone https://github.com/llSourcell/Q-Learning-for-Trading.git

Cloning into 'Q-Learning-for-Trading'...
remote: Enumerating objects: 25, done.
remote: Total 25 (delta 0), reused 0 (delta 0), pack-reused 25
Unpacking objects: 100% (25/25), done.

cd /content/Q-Learning-for-Trading

/content/Q-Learning-for-Trading

!python run.py --mode train

2021-01-05 07:58:40.758674: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.1
Traceback (most recent call last):
File "run.py", line 35, in <module>
env = TradingEnv(train_data, args.initial_invest)
File "/content/Q-Learning-for-Trading/envs.py", line 43, in __init__
self.observation_space = spaces.MultiDiscrete(stock_range + price_range + cash_in_hand_range)
File "/usr/local/lib/python3.6/dist-packages/gym/spaces/multi_discrete.py", line 30, in __init__
assert (np.array(nvec) > 0).all(), 'nvec (counts) have to be positive'
AssertionError: nvec (counts) have to be positive

or you may copy to the below link to access directly from Colab notebook.

https://colab.research.google.com/drive/10b1ynKtH5EI8yD5wV1B1DBzBZ7O_aQHB#scrollTo=vglrR3IJkTUU


RE: Colab, Github, starts - itriIA - Oct-23-2021

For Error :
File "/usr/local/lib/python3.6/dist-packages/gym/spaces/multi_discrete.py", line 30, in __init__
assert (np.array(nvec) > 0).all(), 'nvec (counts) have to be positive'
AssertionError: nvec (counts) have to be positive

----------------> I had the same issue, You can resolve it by downgrading Gym to 0.9.5 max