Unable to properly install pip3 for python3 - python

I am having trouble properly installing pip3 for python3. It appears that I have installed pip and pip3 successfully.
whereis pip
pip: /usr/local/bin/pip /usr/local/bin/pip3.7
whereis pip3
pip3: /usr/bin/pip3 /usr/local/bin/pip3 /usr/local/bin/pip3.7 /usr/share/man/man1/pip3.1.gz
What makes me curious is when I type:
pip --version
pip 19.0.3 from /home/fmd/.local/lib/python3.6/site-packages/pip (python 3.6)
This gives proper result but when I do the same for pip3 I this:
pip3 --version
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
ImportError: cannot import name 'main'
I have referred
https://pip.pypa.io/en/stable/installing/
How do you uninstall the package manager "pip", if installed from source?. And tried to uninstalling and reinstalling pip3 but it dosent seem to work I get the same error as above. How do I remove this error?
My system is:
> NAME="Ubuntu" VERSION="18.04.2 LTS (Bionic Beaver)" ID=ubuntu
> ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.2 LTS" VERSION_ID="18.04"

My bad seems like I installed pip3.7 binary
pip3.7 --version
pip 19.0.3 from /home/fmd/.local/lib/python3.6/site-packages/pip (python 3.6)
I would install python3 dependencies using pip3.7 rather than pip3
for example pip3.7 install numpy and so on.

Related

ModuleNotFoundError: No module named 'pip._internal.cli'

Need some help here.
I have two versions of pip and pip3 installed in different location.
When I try to do a pip install package-name it throws Error as:
ModuleNotFoundError: No module named 'pip._internal.cli'
pip 18.1 from /project/miniconda/lib/python3.7/site-packages/pip (python 3.7)
$ which pip
/project/miniconda/bin/pip
$ which pip3
/usr/local/bin/pip3
$ pip -V
pip 18.1 from /project/miniconda/lib/python3.7/site-packages/pip (python 3.7)
$ pip3 -V
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 7, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal.cli'```
Since I don't have super user access, I cannot modify pip._internal.cli.main to pip.internal.cli.main.
Please help.
Please upgrade pip with python -m pip install --upgrade --force-reinstall pip.
You can try to install any package with: python -m pip install package-name for python2.7 and python3 -m pip install package-name for python3.
Using python -m pip install instead of just pip install is recommended. The reason is that it will use the correct interpreter for your python installation, specially if you have many versions installed. More details here: https://snarky.ca/why-you-should-use-python-m-pip/
Try this it worked for me
python3 -m pip install --user --upgrade pip
Image Link for code

How to install pip globally on Ubuntu 20.04, so that all users can use it the same way?

I set up a VMware machine under Windows 10, running Ubuntu 20.04.
The first thing I did after the installation was to install pip:
sudo apt install python3-pip
I then did:
sudo pip3 install --upgrade pip3
to which I got an error saying that the package pip3 doesn't exist. So I did:
sudo pip3 install --updgrade pip
which finished and installed pip 21.0.1
Now if I run pip3 with sudo, I have to type sudo pip3, but for a non-root user I have to use pip insted of pip3
sudo pip3 --version and sudo pip --version and pip --version return the same:
pip 21.0.1 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
But pip3 --version returns: bash: /usr/bin/pip3: No such file or directory
I just want to use the command pip3 both with and without root privilige and I don't understand what's happening here.
bash: /usr/bin/pip3: No such file or directory
This is because bash still remembers where it saw pip3 last time and the place was changed from /usr/bin/pip3 to /usr/local/bin/pip3. To clear its memory run hash -r. See command hash in bash manual.

Pip does not install in USER_SITE

my specific problem is with pip 9.0.3 (no other version tested) on linux.
When I try to install a package for locally for my linux user using
$ pip3 install --user numpy
...
Successfully installed numpy-1.18.1
I get
$ python3 -m numpy
/usr/bin/python3: No module named numpy
As far as I know, pip3 should install in
$ python3 -m site
...
USER_BASE: '/home/username/.local' (exists)
USER_SITE: '/home/username/.local/lib/python3.6/site-packages' (exists)
ENABLE_USER_SITE: True
but the directory is empty.
But what I've found are modules in /home/username/.username/modules which seems to be installed by pip3.
How can I configure pip to use the correct USER_SITE?
Q: Which pip/python is used?
$ which pip3
/usr/bin/pip3
$ pip3 --version
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)
$ python3 --version
Python 3.6.8
Q: how does sys.path looks like?
$ python3
>>> import sys
>>> sys.path
['', '/usr/lib64/python36.zip', '/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', '/home/username/.local/lib/python3.6/site-packages', '/usr/lib64/python3.6/site-packages', '/usr/lib/python3.6/site-packages']
Q: Have you tried to upgrade your pip first?
I have no super-user privileges on this machine (why I try to install in USER_SITE).
Q: Do you have local configuration files like here?
The online doc describes pip 20.0.2 instead of 9.0.3 or similar.
However, there are no such config files like
/home/username/.config/pip/pip.conf
/home/username/.pip/pip.conf
/etc/pip.conf
/etc/xdg/pip/pip.conf
Q: have you tried to install/upgrade in USER_SITE?
Yes. But without the correct path, it will not work.
$ python3 -m pip install -U --user pip
...
Successfully installed pip-20.0.2
$ which pip
~/.username/scripts/pip
$ pip --version
Traceback (most recent call last):
File "/home/username/.username/scripts/pip", line 7, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal'

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...

No matching distribution found for PyQt5

I install a rasbian os on my vmware workstation and I am currently trying to install some packages and modules. I have a problem with pip. I try:
sudo pip install PyQt5
sudo pip3 install pyqt5
sudo python3 -m pip install PyQt5
I got the same error.
ERROR: Could not find a version that satisfies the requirement pyqt5 (from versions: none)
ERROR: No matching distribution found for pyqt5
I try to install PyQt5 manually and for that I install sip with sudo pip3 install sip after that I try to configure pyqt5 files with python configure.py but I got this error:
Error: Unable to import PyQt5.sip. Make sure you have configured SIP to create a private copy of the sip module.
I already install sip. But my main problem is about pip. It's not working like I expect
I'm not sure if it's about pip or it is a problem about operating system (or if it is about me).
python --version:2.7.16
python3 --version:3.7.3
pip --version I got the error
Traceback (most recent call last):
File "/usr/local/bin/pip", line 6, in <module>
from pip._internal.main import main
ImportError: No module named main
sudo pip --version :19.3.1
pip3 --version :18.1
lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster
I had some error, when tried to install on virtualenv. It helped me:
pip install --upgrade pip
Before I had 19.0.3 versin and upgraded to 22.0.4
then:
pip install PyQt5

Categories

Resources