python error with No module named 'mlrose' - python

I have tried
pip install mlrose
pip3 install mlrose
sudo pip install mlrose
they all show the Requirement already satisfied, but when I come to Jupyterlab to implement import mlrose, it raises an error
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-e28c59840eed> in <module>
----> 1 import mlrose
ModuleNotFoundError: No module named 'mlrose'

Install your packages direct from Jupyter notebook, then you can be sure that the packages are being installed into the local python instance.
! pip install --user <package>
The ! tells the notebook to execute the cell as a shell command.
Then try:
conda update --all

Related

Pipenv "ModuleNotFoundError: No module named 'pip'" after upgrading to python3.7

I am using ubuntu 18. The default python3 version is 3.6. I updated to 3.7 today and update the alternatives to point to python3.7.
I can use python3.7 by typing python3. I can also use pip3 --version (20.0.2).
I can activate the virtual environment by using pipenv shell. But I cannot install package using pipenv install . It gives me the following error:
pipenv.exceptions.InstallError]: ['Traceback (most recent call last):', ' File "/home/johnchan/.local/share/virtualenvs/src-lkQYyAWf/bin/pip", line 5, in <module>', ' from p
ip._internal.cli.main import main', "ModuleNotFoundError: No module named 'pip'"]
ERROR: ERROR: Package installation failed...
Running which pip3: /usr/local/bin/pip3
Running which pipenv: /usr/local/bin/pipenv
Type pip3 inside pipenv gives:
Traceback (most recent call last):
File "/home/johnchan/.local/share/virtualenvs/src-lkQYyAWf/bin/pip3", line 5, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'
python2 -m pip install --user --upgrade pip
python3 -m pip install --user --upgrade pip
After upgrading pip (or pip3, in this case) if the following occurs:
$ ~ pip3 -V
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip._internal import main
ModuleNotFoundError: No module named 'pip._internal'
Force a reinstall of pip:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --force-reinstall
Verify install:
$ ~ pip3 -V
pip 10.0.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
Now pip3 install <package> and pip3 install --user <package> (for user-level installs) will work correctly.
There should never, ever be any reason you need to run pip in elevated mode.
(note: For Python 2.7, just replace python for python3, and pip for pip3)
Had the same issue on macOS as well, it's a common issue across platforms.
I found the answer here:
Setting up a virtualenv: No module named 'pip'
Seems like it is a bug.
I install pipenv using --re flag which is equivalent to virtualenv venv --no-setuptools.
Then I run python get-pip.py inside pipenv.
It works. I can install package now.
But I don't know the reason why...

Why is my pip braking after updating

My pip broke after I ran
pip install --upgrade pip
When I run this command
pip -V
or any other commands I get
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError: cannot import name main
Why is it breaking? I have python3 installed. I have a solution but I need to understand why it broke after upgrading to the latest version.
pip authors were warning for many years to not import pip. Finally at version 10 they restructured their code.
Your /usr/bin/pip was not upgraded (probably because pip install -U pip installed new /usr/local/bin/pip) so it uses the old API before renaming.
If that's the case I recommend to put /usr/local/bin before /usr/bin in $PATH.

Some issues with pip installation

I tried to install pip manager using the file get-pip.py as mentioned in the documentation- https://pip.pypa.io/en/stable/installing/
So, I downloaded the file and ran python get-pip.py and as a result, I had permission issues. So I again ran sudo python get-pip.py and it worked.
Now I wanted to install numpy. So I ran pip install numpy and it showed me the Import Error saying-
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip import main
ImportError: No module named pip
But again when I ran sudo pip install numpy, it worked and got installed. Now, for every python script involving these pip packages, I have to run the script using sudo which I don't like. So how can I resolve these permission issues?
Just to mention-
python v2.7.12
pip v9.0.1
pip installation location- /usr/local/lib/python2.7/dist-packages

Problems Installing pip on CentOS 5.x

I have pip installed:
[amr#h2oamr kits]$ python get-pip.py
Requirement already up-to-date: pip in /usr/local/lib/python2.7/site-packages
However, I'm getting this error when trying to install Django:
[amr#h2oamr kits]$ pip install django
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in ?
from pip import main
ImportError: No module named pip
I am stuck trying to move forward. I installed pip as recommended by using a get-pip.py module I downloaded.
This upgrade also did not work.
[amr#h2oamr kits]$ pip install --upgrade pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in ?
from pip import main
ImportError: No module named pip
How can I remove pip altogether, and then re-install it?
you can use the command $ rm pip to remove pip and then $sudo apt-get install pip to get the latest version

How to install a package with pip locally?

Hello I've installed a local version of pip using
python get-pip.py --user
After that I can't find the path of pip, so I run:
python -m pip install --user Cython
Finally I can't import Cython
import Cython
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'Cython'
Use virtualenv, it is used to create isolated python environments (check this quick guide http://docs.python-guide.org/en/latest/dev/virtualenvs/ )
python -m pip install --user Cython
should probabably be
pip install --user cython

Categories

Resources