Cyberithub

Solved: "/usr/bin/python3: No module named pip" error on Linux

Advertisements

In this article, we will look into how to solve "/usr/bin/python3: No module named pip" error which I believe is a pretty common error in a freshly built Linux System where python3 packages are not installed yet. pip is a very famous python package management tool frequently used by Python Programmers and developers to manage their application packages. If you don't have pip installed before you are trying to install any of the python modules then you will always end up with "/usr/bin/python3: No module named pip" error just like what I encountered last night. While this may not be the only reason to have this error but this is the common most reason for lot of folks !!

Solved: "/usr/bin/python3: No module named pip" error on Linux

Solved: /usr/bin/python3: No module named pip error on Linux

Also Read: How to Check and Log Malicious RPM Installation in 3 Easy Steps

Advertisements

So when I was trying to install a package using pip, I encountered below error in my Ubuntu 20.04 LTS System. You might be getting the same error in different Linux version.

root@cyberithub:~# python3 -m pip install --user pipenv
/usr/bin/python3: No module named pip

While this error can come due to multiple reasons but in most of the cases you will see this error because of pip package not installed in your System. So to solve this kind of error, you need to simply install pip package from the default Repo. For example, in my case I have used apt-get install python3-pip command to install this package in my System. More about PIP.

Advertisements

NOTE:

Please note that here I am using root user to run all the below commands. You can use any user with sudo access to run all these commands. For more information Please check Step by Step: How to Add User to Sudoers to provide sudo access to the User.
root@cyberithub:~# apt-get install python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
dmeventd libaio1 libdevmapper-event1.02.1 liblvm2cmd2.03 libreadline5 thin-provisioning-tools
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
binutils binutils-common binutils-x86-64-linux-gnu build-essential dpkg-dev fakeroot g++ g++-9 gcc gcc-9 libalgorithm-diff-perl libalgorithm-diff-xs-perl
libalgorithm-merge-perl libasan5 libatomic1 libbinutils libc-dev-bin libc6-dev libcrypt-dev libctf-nobfd0 libctf0 libexpat1-dev libfakeroot libgcc-9-dev
libitm1 liblsan0 libpython3-dev libpython3.8-dev libquadmath0 libstdc++-9-dev libtsan0 libubsan1 linux-libc-dev make manpages-dev python-pip-whl
python3-dev python3-distutils python3-setuptools python3-wheel python3.8-dev zlib1g-dev
Suggested packages:
binutils-doc debian-keyring g++-multilib g++-9-multilib gcc-9-doc gcc-multilib autoconf automake libtool flex bison gcc-doc gcc-9-multilib gcc-9-locales
glibc-doc libstdc++-9-doc make-doc python-setuptools-doc
The following NEW packages will be installed:
binutils binutils-common binutils-x86-64-linux-gnu build-essential dpkg-dev fakeroot g++ g++-9 gcc gcc-9 libalgorithm-diff-perl libalgorithm-diff-xs-perl
libalgorithm-merge-perl libasan5 libatomic1 libbinutils libc-dev-bin libc6-dev libcrypt-dev libctf-nobfd0 libctf0 libexpat1-dev libfakeroot libgcc-9-dev
libitm1 liblsan0 libpython3-dev libpython3.8-dev libquadmath0 libstdc++-9-dev libtsan0 libubsan1 linux-libc-dev make manpages-dev python-pip-whl
python3-dev python3-distutils python3-pip python3-setuptools python3-wheel python3.8-dev zlib1g-dev
0 upgraded, 43 newly installed, 0 to remove and 171 not upgraded.
Need to get 41.7 MB of archives.
After this operation, 185 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
........................................

If you are using RHEL/CentOS 7 based Systems, then all you need to do in to enable the EPEL Repo and then install the package by using yum install python3-pip command. For RHEL/CentOS 8 based Systems, you can use dnf install python3-pip command.

Advertisements
yum install python3-pip 
dnf install python3-pip

After successful installation, you can verify the package version by using pip --version command as shown below.

root@cyberithub:~# pip --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

After installing the package I again tried to run the earlier command then this time I noticed that the command worked successfully and now it is not throwing "/usr/bin/python3: No module named pip" error as shown below. Hope this helps !!

Advertisements
root@cyberithub:~# python3 -m pip install --user pipenv
Collecting pipenv
Downloading pipenv-2022.1.8-py2.py3-none-any.whl (3.6 MB)
|████████████████████████████████| 3.6 MB 1.4 MB/s
Requirement already satisfied: pip>=18.0 in /usr/lib/python3/dist-packages (from pipenv) (20.0.2)
Collecting virtualenv
Downloading virtualenv-20.13.2-py2.py3-none-any.whl (8.7 MB)
|████████████████████████████████| 8.7 MB 11.2 MB/s
Collecting virtualenv-clone>=0.2.5
Downloading virtualenv_clone-0.5.7-py3-none-any.whl (6.6 kB)
Requirement already satisfied: certifi in /usr/lib/python3/dist-packages (from pipenv) (2019.11.28)
Requirement already satisfied: setuptools>=36.2.1 in /usr/lib/python3/dist-packages (from pipenv) (45.2.0)
Requirement already satisfied: six<2,>=1.9.0 in /usr/lib/python3/dist-packages (from virtualenv->pipenv) (1.14.0)
Collecting distlib<1,>=0.3.1
Downloading distlib-0.3.4-py2.py3-none-any.whl (461 kB)
|████████████████████████████████| 461 kB 16.4 MB/s
Collecting filelock<4,>=3.2
Downloading filelock-3.6.0-py3-none-any.whl (10.0 kB)
Collecting platformdirs<3,>=2
Downloading platformdirs-2.5.1-py3-none-any.whl (14 kB)
Installing collected packages: distlib, filelock, platformdirs, virtualenv, virtualenv-clone, pipenv
WARNING: The script virtualenv is installed in '/root/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script virtualenv-clone is installed in '/root/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The scripts pipenv and pipenv-resolver are installed in '/root/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed distlib-0.3.4 filelock-3.6.0 pipenv-2022.1.8 platformdirs-2.5.1 virtualenv-20.13.2 virtualenv-clone-0.5.7

4 thoughts on “Solved: "/usr/bin/python3: No module named pip" error on Linux”

Leave a Comment