No module named spinup.run - python

Today, I tried to install the spinning up in deep RL from openai. When I copied python -m spinup.run ppo --env CartPole-v1 --exp_name hello_world in Anaconda, it showed that
No module named spinup.run.
Actually, I installed spinup package. I did not find the spinup.run package.
Does anyone know how to solve this problem so that I can successfully install spinning up in deep RL?
Thanks!

That tripped me up too. I forgot I had to restart the environment ---
Before you open your IDE you need to activate the environment. I'm using Spyder in Anaconda so I open up a terminal and type the following:
source activate spinningup
anaconda-navigator &
... and then I open up the Spyder editor. Replace Anaconda or Spyder with which ever IDE you are using

You need to make sure you have the packages installed correctly, which you can find in the installation section of the OpenAI SpinningUp website. If you have successfully installed everything, run:
python -m spinup.run ppo --exp_name CartPole --env CartPole-v0

Related

Installed Python 3, now my Anaconda environment is messed up

I apologize in advance for my poor vocabulary - I do not know much about environments, paths, and things of the sort. I am on macOS Catalina.
I created a program using Spyder from Anaconda. My program uses packages like pandas and numpy which are built into Anaconda. I used to be able to run the program in Terminal with the command: $ python3 app.py.
However, I recently downloaded Python 3.9.1 from https://www.python.org/downloads/mac-osx/. Ever since then, I have been unable to run the program in Terminal because of missing package errors like
import numpy as np
ModuleNotFoundError: No module named 'numpy'
I went to my applications folder, right clicked on Python 3.9.1, and clicked Move To Trash. This did not solve my problem. I reinstalled Anaconda (I did not uninstall it - just simply installed again), but that also did not solve my problem. I am able to run the program in Spyder (from Anaconda), but I wish to run it in Terminal again.
I believe the solution is simple, but I am not sure what to do. I have tried searching and reading but I am not familiar with the terminology. I think I just need to reset the environment, but I am not sure.
Anaconda is used for creating closed enviorments, so you don't need to thrash your computer with global packages.
Imagine you have 2 different projects. Project A works only on python 3.2 and Project B works on 3.8.
That's where anaconda comes in.Managing enviorments with conda
conda create -n PROJECTA python=3.2
conda create -n PROJECTB python=3.8
Now activate env you wish to work with. For macOS
source activate PROJECTA
Now you should see (PROJECTA) instead of (base)
Now inside this PROJECTA you can install modules you require like
pip install numpy
and when executing .py file
move to dir with your app.py file and
python3 app.py
this will be opened in conda enviorment you created and activated, using modules you installed in this env.
You can still edit py file and execute it through shell, but it will throw errors if you try to run it from IDE without linking project to respected conda enviorment.
If you are using PyCharm Configure a Conda vir env in PyCharm
You must create separate environments for every projects or it will get messed up.
conda create -n name_of_environment python=3.6
You must not delete the python folder into trash rather uninstall it Python 3.9.1 and remove its path from the directory.
In short if you run python from terminal and it is not supporting your Installed anaconda packages . You should use anaconda prompt instead of CMD.
Because your anaconda is not added to path rather then it picks up the python 3.9 you have installed from Python 3.9.1 from https://www.python.org/downloads/mac-osx/. ( This is the python with separate environment then anaconda so it wont detect anaconda packages ).
When you run the cmd and enter python it runs the python that you downloaded and installed rather then Anaconda
At the time of installing anaconda it gives option to add conda variables to path you can select those at installing stage / or add manually

Module not found in pycharm (Windows)

I wanted to install Pytorch via anaconda and it worked but PyCharm can't find the module (
ModuleNotFoundError: No module named 'torch'
I also have CUDA installed but when I looked up to add a the package with pycharm it also gives an error. When I added the anaconda interpreter I can't run the code. I use Python 3.6
Ok I solved this problem: First install anaconda and open the prompt then type conda install pytorch -c pytorch and pip3 install torchvision. Then go to PyCharm and create an Project and set the Project Interpreter to the Anaconda one (there is in the path: \Anaconda.x.x\python.exe ). Then you go to the Run settings and click Run... and then you go to Edit Configurations and then you select the Project Default interpreter and apply and you should be done! Thanks to the ppl who helped me =)
In you are on ubuntu and have installed pytorch using anaconda then in the interpreter of the pycharm which is under
File -> Settings -> Interpreter you have to do following:
search for the conda where it is installed by doing where conda then in that you will find a python.exe in your environment folder provide the path of that in the python interpreter.
Try with this it should work as I was facing the similar issue on windows solved it using this procedure.
And probably where conda won't work if you don't have support for ubuntu commands in windows than you can go to the folder where Anaconda is there which probably will be in your Users -> 'Your User' folder in that search for you environment and in that go to your environment and find python.exe give this path in pycharm.

Tensorflow GPU - Spyder

I am having a problem with importing tensorflow GPU on spyder.
This is what I get when I type import tensorflow on iPython using Spyder 3 (on MacOS)
When I checked what packages I have within tensorflow I get this list, which I see that iPython, and Spyder are not included.
Also in anaconda, when I click on tensorflow in Environments, I have the option to open it with Python, with terminal, but not with iPython or Spyder (or Jupyter)
I would very much appreciate any help.
UPDATE 1:
Ok I managed to get Spyder on tensorflow's ENV but when I run the command 'import tensorflow' on iPython I get this error (when I run the same command on Python's tab everything seems to work just fine.
Finally I solved this mystery. If you have installed Spyder from the Anaconda, go to the Anaconda launcher. There go to environments, you will see two of them: root and tensorflow. The latter one is created due to the instructions by tensorflow.org. Just run all those instructions on the root, don't activate tensorflow environment, it will work. Everything will be available in spyder.
The instructions mentioned on the (https://www.tensorflow.org/install/install_windows) link do NOT work for the Ananconda/Spyder setups on windows. Having struggled through this for hours below is the easiest solution to get this working. Hope this helps!
Basically you do NOT need to create a seperate tensorflow environment if you want to run this on spyder. Use the below commands to install tensorflow on the ananconda client.
1) Open the Ananconda prompt from the installation folder in the start menu.
2) Run below commands:
conda install pyqt
conda install tensorflow
Spyder is picking up the default Anaconda Env, whereas you have tensorflow install in a separate environment tensorflow
To work with Spyder & tensorflow, install tensor flow and openssl in default ENV
I figured out how to get this working using the instruction on Tensorflow link. Once you create the tensorflow enviroment you can Spyder(Tensorflow) in your ananconda start menu folder. If you run your code by opening this the tensorflow should work.
Using the Anaconda Navigator:
It works for me in a different way:
As tensorflow is separately created environment, install spyder in tensorflow envirnment.
(Anaconda>Home>Applications on>tensorflow>spyder>install ... wait for installation to complete and ten launch)
I have seen another issue in anaconda. If you install Tensor flow in root or custom environment (like 'tensorflow') its not accessible from jupyter notebook or spyder. The best way to do this is to install it in the administrator mode. Follow these steps:
Open "Anaconda Prompt" as an administrator.
Verify the status on top written "Administrator: Anaconda Prompt"
DON'T Activate any of the environments, root or tensorflow.
Type in the command "pip install --ignore-installed --upgrade tensorflow-gpu" to install Tensorflow with GPU support.
To install Keras type "conda install -c conda-forge keras"
To verify installation, type 'python' and then inside python env. type 'import tensorflow as tf'. If all is well it will work without error.
I faced the same issue and solved by performing following steps in order.
Assuming that you have created conda environment, installed tensorflow and activated it and also installed spyder.
Check the executable python of your conda environment
>>import sys
>>sys.executable
Note the path of python executable.
Go to Spyder preferences and set the interpreter path to the one noted above.

spyder/juypter not working after downgrading python

I had to download my python version from 3.5 to 3.4 because one of the packages I needed wasn't supported in 3.5. I downgraded the python version using the conda command prompt, and everything worked fine - got my package to install with all its dependencies and no conflicts. But now when I try to open Juypter notebook or Spyder, nothing happens. My IPython works just fine. I'm thinking maybe i have to downgrade Juypter and Spyder, but I'm not sure. Anyone have any ideas?
After a day of searching I finally figured it out.
I initially used
conda install python=3.4
Bad idea - ended up having to do a fresh install of anaconda to get spyder and juypter working again.
What ended up working is creating a separate environment.
conda create -n py34 python=3.4 anaconda
activate py34
... then install packages ...
This added spyder(py34), juypter(py34), and all its "py34 brothers and sisters" to my start menu. Using these new shortcuts/environment, I now have access to the packages I need by choosing the appropriate short cut. Yes, my start menu has extra python shortcuts now, but whatever - it works.
Just make sure Make sure you install the packages you're looking for before you close the anaconda console. Perfect for installing theano dependencies mingw and libpython.

Installing IbPy to be used in spyder (anaconda)

I have installed Anaconda and currently using Spyder IDE.
I am trying to install a package (IbPy -> https://github.com/blampe/IbPy) so that it can be used in Spyder.
So far I tried pip install ibpy, as well as conda install ibpy, but without success since the package is not available in the anaconda repository where I would normally update and download the most common packages.
I have also tried to move the folder downloaded from GitHub to the correct site-packages folder of Anaconda (C:\Users\Username\Anaconda2\Lib\site-packages), but still it does not work.
I also tried to run the setup.py (shift + right click on the folder, open new process here, Setup.py install), but without any success.
I tried to look for a solution everywhere, but I have had no luck so far.
If someone more tech savvy than me and practical with these specific could help, it would be highly appreciated.
You need to install it from github. Use the following.
pip install https://github.com/blampe/IbPy/zipball/master
You need to do a open terminal from the Anaconda Navigator and run the command:
conda install -c tibkiss ibpy2

Categories

Resources