Python Forum

Full Version: Colab, Github, starts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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...rading.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
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...rading.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/...lrR3IJkTUU
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