Unagi
September 16, 2022, 4:25am
1
Hello,
I´m trying to run some code using Jupyter and I can´t find a way of installing gym.
This is the code:
!pip install gym==0.18
import gym
After all the "Requirement already satisfied"s (since I had already installed it) it says:
ModuleNotFoundError Traceback (most recent call last)
Input In [2], in <cell line: 2>()
1 get_ipython().system(‘pip install gym’)
----> 2 import gym
ModuleNotFoundError: No module named ‘gym’
The same happens if I try to !install gym (no version).
It worked before, however I created a new environment in Jupyter for this course and it stopped working.
I tried installing it using Terminal several ways, however, this shouldn´t be so complicated, right?
Thanks in advance.
1 Like
dear Unagi.
Thank you for your contribution to the Anaconda community.
It worked before, however I created a new environment in Jupyter for this course and it stopped working
If you create a new environment, the new PATH will be applied to Jupyter. So installed packages get lost and IPython spits out his ModuleFoundError.
Therefore, the following article was already written five years ago, and I think it will be helpful.
https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/
Similarly, there is an article at the following URL as a precaution when using pip in the Anaconda environment, so it would be good to refer to it.
Unfortunately, issues can arise when conda and pip are used together to create an environment, especially when the tools are used back-to-back multiple times, establishing a state that can be hard to reproduce. Most of these issues stem from that...
Est. reading time: 5 minutes
Best regards
ktsh.tanaka.2020