Error importing gym using Jupyter Notebook - python

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 don´t specify a version, and use only "gym".
I tried installing it using Terminal several ways, however, this shouldn´t be so complicated, right?
Please help.
Thanks in advance.

Related

ModuleNotFoundError: No module named 'web3' on jupyter notebook

I am trying to run the following code in Jupyter Notebook using Anaconda (I used pip to install web3):
from web3 import Web3
w3=web3.Web3(web3.Web3.HTTPProvider("http://172.18.0.1:8545"))
w3=util.connect(host="172.18.0.8",port="8545",poa=True)
assert w3.isConnected()
However, I get this Error Stack:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-10-0c63a16e1a59> in <module>
----> 1 from web3 import Web3
2
3 w3=web3.Web3(web3.Web3.HTTPProvider("http://172.18.0.1:8545"))
4 w3=util.connect(host="172.18.0.8",port="8545",poa=True)
5 assert w3.isConnected()
ModuleNotFoundError: No module named 'web3'
Anyone knows how to resolve this?
Okay, so I managed to find the answer myself with the help of #NicolaLandro: I did not use the command in the notebook.
However it worked, when I tried pip install web3 inside the conda prompt, after activating conda environment.

how do you import my own module on colab?

I developp on colab and i save my code to create my own module qrl.py on drive but in my qrl.y i use !pip install deplacy and import numpy.
if i try to import the module i have the error following
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-58-62dca1f58066> in <module>()
----> 1 import grl
ModuleNotFoundError: No module named 'grl'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
Trying copying the file to /content/ and build your module there. It's not able to access qrl.py (or grl) file.

AttributeError: type object 'Wav2Vec2ForCTC' has no attribute 'from_pretrained'

I am trying to fine tune Wav2Vec2 model for medical vocabulary. When I try to run the following code on my VS Code Jupyter notebook, I am getting an error, but when I run the same thing on Google Colab, it works fine.
from transformers import Wav2Vec2ForCTC
model = Wav2Vec2ForCTC.from_pretrained(
"facebook/wav2vec2-base",
gradient_checkpointing=True,
ctc_loss_reduction="mean",
pad_token_id=processor.tokenizer.pad_token_id,
)
And here is the error that I getting on my VS Code
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-59-926a81051d7b> in <module>
1 from transformers import Wav2Vec2ForCTC
2
----> 3 model = Wav2Vec2ForCTC.from_pretrained(
4 "facebook/wav2vec2-base",
5 gradient_checkpointing=True,
AttributeError: type object 'Wav2Vec2ForCTC' has no attribute 'from_pretrained'
Issue solved when I uninstalled both the libraries and installed their respective versions needed using following command:
pip uninstall huggingface-hub
pip uninstall transformers
pip install huggingface-hub==0.0.8
pip install transformers==4.6.1
After this the issue got resolved.

Python/Jupyter Notebook Not finding modules...?

I just got done writing a pretty good rock paper scissors game and now when I try to import it and run the cell I'm getting this:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-8d3be5084430> in <module>
----> 1 import RPSgame.py
ModuleNotFoundError: No module named 'RPSgame.py'; 'RPSgame' is not a package
What is causing this and how can I fix it? I'm running Jupyter Notebook through Anaconda Navigator
It might be related to how you are importing the .py file
This link might help: How to import other Python files?
You shall try this:
import .RPSgame

Issue implementing pandas_datareader module

On MacOs
Jupyter Notebook
I'm having issues trying to implement a pandas module, I did pip list and it says that it is installed, so I'm not sure why I get
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-6-84d930aeb84e> in <module>
----> 1 from pandas_datareader import data as wb
ModuleNotFoundError: No module named 'pandas_datareader'
is there something else I need? Thanks.
I'm not sure why it's not working, I tried on VScode as well.

Categories

Resources