ModuleNotFoundError: No module named 'web3' on jupyter notebook - python

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.

Related

Why does the pattern package fails to be imported in jupyter notebook yet it is already installed

I installed pattern3 in the cmd with: pip install pattern3
and it was successful I also installed in the jupyter notebook and still it was successful.
However, when I try to import it with import patterns I get this error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_2116/1948699844.py in <module>
----> 1 import patterns
ModuleNotFoundError: No module named 'patterns'
I think you have made a typo. The import statement for the pattern3 module would be import pattern3, not import patterns.
If you have installed the pattern3 module correctly, you should be able to import it by using the new statement.

Error importing gym using Jupyter Notebook

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.

Python No module named 'TikTok Api'

Im trying to figure out where the problem is.
When I run the code, I got an error "Traceback (most recent call last):
File "C:\Users\user\IdeaProjects\tiktokAnalyse.idea\main\main.py", line 2, in
import TikTokApi
ModuleNotFoundError: No module named 'TikTokApi' "
Ive installed "pip install TiKTokApi" and imported with
"from TikTokApi import TikTokApi"
Cant figure out where the problem is...
make sure you pip installed it, if the issue is still there, restart the editor. also, check if you have activated the environment in which you pip installed the module(if you are using anaconda)

Submodule import not working on Google Colab

I have a package called boo which I install on google colab from a github repository. The installation process looks fine and results in success message Successfully installed boo-0.1. However import boo fails on first internal import.
I replicated the same installation steps in a local virtual environment and package worked, but not on collab.
Here are my steps and error trace:
!rm -rf sandbox
!git clone https://github.com/ru-corporate/sandbox.git
!pip install -r sandbox/requirements.txt
!pip install sandbox/.
Alternatively, I tried
!pip install git+https://github.com/ru-corporate/sandbox.git#master
The error trace is:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-fc0b1d036b35> in <module>()
----> 1 import boo
/usr/local/lib/python3.6/dist-packages/boo/__init__.py in <module>()
----> 1 from boo.boo import download, build, read_dataframe, files
2 from boo.views.whatis import whatis
/usr/local/lib/python3.6/dist-packages/boo/boo.py in <module>()
3 from tqdm import tqdm
4
----> 5 from boo.file.download import curl
Basically, from root __init__.py the import goes to root boo.py and stumbles upon finding boo/file/download.py.
How do I make this package work on collab?
I could fix the subpackage behavior by editing setup.py as suggested here:
# ...
packages=setuptools.find_packages()
# ...
Somehow Colab is more restrictive on this parameter than local installation.

Getting numpy error when using azureml-sdk

hy I followed the installation instructions here
and installed with
pip install --upgrade azureml-sdk[notebooks,automl] azureml-dataprep --ignore-installed PyYAML
It seem to work but a simple
import azureml.core
azureml.core.VERSION
Throws me a numpy error
> AttributeError Traceback (most recent call
> last) <ipython-input-3-08b704cd5542> in <module>
> ----> 1 import azureml.core
> 2 azureml.core.VERSION
c:\users\werth\appdata\local\continuum\anaconda3\envs\azuresdk\lib\site-packages\azureml\core\__init__.py in <module>
4
5 """Setup file for core package."""
----> 6 from azureml.core.workspace import Workspace
7 from azureml.core.experiment import Experiment
8 from azureml.core.runconfig import RunConfiguration
... I did not include the total traceback as it is apparently a Azure import problem.
AttributeError: type object 'numpy.ndarray' has no attribute '__array_function__'
It seems that the workspace has a problem. But I cannot think why. The Notebook is in a subfolder of the working directory. Numpy is installed.
If you would have an idea I would be thankfull.
Hi greatest Floridaman,
the answer is simple. During the installation of the azureml-train-automl 1.0.8 package, the numpy package needs to be maximum at version 1.15.0
So just downgrade numpy to that version
conda install numpy=1.15.0

Categories

Resources