pip commands not able to install packages successfully - python

I am unable to successfully install packages from pip commands in my jupyter notebook. Each time I use pip commands, it shows:
Example: pip install matplotlib
Requirement already satisfied: .....
WARNING: Ignoring invalid distribution -umpy(appdata\local\continuum\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy(appdata\local\continuum\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy(appdata\local\continuum\anaconda3\lib\site-packages)
I tried different commands like sudo, !, python -m pip. But nothing works. I am constantly getting
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
pip version: pip 21.2.4 from C:\Users\AppData\Local\Continuum\anaconda3\lib\site-packages\pip (python 3.7)

Use the direct pip of your python using the command:
my/path/to/python -m pip install matplotlib
Often pip is linked with python 2.7 if you have it.
Then pip3 is linked with your first python3 installation.
You have to use directly python -m pip to be sure you are installing modules in the right python directory.

Related

ModuleNotFoundError: No module named 'kmodes'

I have tried installing it using pip install kmodes and it says that "Requirement is satisfied" but am not being able to import the library even after that.
The list of libraries doesn't have kmodes even after installing. Attaching screenshot for reference. What is happening here?
from kmodes.kprototypes import KPrototypes
ModuleNotFoundError: No module named 'kmodes'
Maybe your PIP is installing to the wrong version of python and the code you are running is being interreted by a later version
Try copying your python executable path and running this
C:\Users\username\AppData\Local\Programs\Python\Python39\python.exe -m pip install kmodes
Another reason is that kmodes did not install properly the first time
Try running this as an administrator
pip uninstall kmodes && pip install kmodes

why couldnot I install "seaborn" and "pandas" in ubuntu?

in my code, there are
import seaborn
and they give me
no module named seaborn
when I use
pip install seaborn
it gives me Requirement already satisfied but I still couldnot import seaborn so I use pip3 install seaborn,it reports so many errors as follow:
Using cached https://files.pythonhosted.org/packages/2f/79/f236ab1cfde94bac03d7b58f3f2ab0b1cc71d6a8bda3b25ce370a9fe4ab1/pandas-1.0.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-c8lrjdqb/pandas/setup.py", line 42
f"numpy >= {min_numpy_ver}",
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-c8lrjdqb/pandas/
I don't know how to solve this, and I have upgraded my setuptools like:pip install --upgrade setuptools and also pip3 install --upgrade setuptools
and also I have tried conda install seaborn it looks like work well but when I run my code, it still told me no module name seaborn
so how could I install seaborn on my ubuntu?
I have checked my python version by python --version it is python3.8.
Same problem also happened with install pandas*.
Both python2 and python3 come shipped along with Ubuntu, so installing packages with just pip might be your issue as that is the default package manager for python 2.
Try the following in your terminal:
$ python3 -m pip list | grep seaborn
If you dont get an output then this shows you that seaborn hasn't been installed via pip linked to your python3 interpreter.
It is good practice to install packages for your interpreter specifically as follows:
$ python3 -m pip install <insert name of package here>
Finally to check that the package has installed correctly launch the python3 interpreter within your terminal and try and import the package e.g.
$ python3
>>> import seaborn as sns
Most of the packages for your python distribution should be in the following directory:
$ cd /usr/local/lib/python3.8/dist-packages
The above are just a few pointers to get you started, hope that helped!

"Please upgrade python" when I have 3.7 and "Please upgrade pip" when I have 20.0.2. Why am I getting this error?

I wanted to download the PIL library to crop images on python, but I just can't download the module. Here's what appears on the terminal
$ pip install PIL
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement PIL (from versions: none)
ERROR: No matching distribution found for PIL
Then I tried this out. But another error shows up
$ python3 -m pip install PIL
Could not find a version that satisfies the requirement PIL (from versions: )
No matching distribution found for PIL
You are using pip version 10.0.1, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
So I tried to upgrade my pip. But then this shows up
$ pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already up-to-date: pip in /Library/Python/2.7/site-packages/pip-20.0.2-py2.7.egg (20.0.2)
When I check my pip version it shows this
$ pip --version
pip 20.0.2 from /Library/Python/2.7/site-packages/pip-20.0.2-py2.7.egg/pip (python 2.7)
When I check my python version it shows this
$ python --version
Python 2.7.10
$ python3 --version
Python 3.7.1
So I downloaded pip3 and then tried the command
$ pip3 install PIL
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement PIL (from versions: none)
ERROR: No matching distribution found for PIL
I also tried what they said.
$ python3 -m pip3 install PIL
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3: No module named pip3
Here are some details about my pip and python
$ which pip3
/Library/Frameworks/Python.framework/Versions/3.7/bin/pip3
$ which python3
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
How do I solve this once and for all?
Because python 2 is no longer supported,
Pip2(invoked by either pip or python -m pip) is complaining that you should use python 3. The package manager for python 3 is called pip3(invoked by pip3 or python3 -m pip).
Your pip3 is currently the latest version and you dont need to take any action to upgrade pip3.
If you want to use PIL in python then i recommend you install pillow. Pillow is the PIL of python 3.
You should be able to install pillow with pip3 install Pillow. Pillow supercedes PIL. (unless you specifically want to use PIL with python 2)
Perhaps you want to configure your terminal to alias pip to pip3 so you wont call pip2 by mistake.

ImportError: No module named neurolab

I try to import nuurolab using this code:
import neurolab as nl
But it gives this error :
ModuleNotFoundError: No module named 'neurolab'
Then I try to install neurolab using
sudo pip3 install neurolab
Then this message shows :
Requirement already satisfied: neurolab in /usr/local/lib/python3.5/dist-packages
How to solve this problem?
You are installing the module in the wrong place. By default on Linux there are 2 integrated versions, 2.7 and 3.5 plus the one you installed. It is important not to confuse between them when installing modules or it will end up in the wrong version.
When typed in the terminal:
python brings up 2.7
python3 brings up 3.5
and for python 3.6 it will be python3.6.
pip does this as well.
pip will be for 2.7
pip3 for 3.5
and
pip3.6 for 3.6
So when installing you just have to change which environment you install it in:
sudo python3.6 -m pip install neurolab
If you get an error saying pip3.6 cannot be found, in some cases it may be pip36 otherwise you need to install pip for 3.6 using:
sudo apt install python3.6-pip

Pip mods don't seem to install

So I just downloaded Python 3.6.1 now using pip I tried to download matplotlib.
pip install --user matplotlib
After it's "successful" download I open Python EDGE, import matplotlib only to receive this message.
NameError: name 'matplotlib' is not defined
Could previously using pip on Python 3.5 be the problem?
Install with exactly your version of Python:
python3.6 -m pip install --user matplotlib
or
C:\Python36\python.exe -m pip install --user matplotlib
The probmle is that pip could use a different version of Python.

Categories