Bash: pip: command not found
Stumbling upon bash: pip: command not found
can be daunting. But it usually entails one fact: pip
isn't installed or isn't recognized due to absence from $PATH
.
To install pip on the fly:
python -m ensurepip --upgrade
If pip installation path isn't in your $PATH
, rectify this:
which python
Then enumerate:
export PATH="$PATH:$(dirname $(which python))"
Easy does it: Install via easy_install
Can't find pip? Let easy_install come to the rescue. Use either of the two commands as per your Python version:
sudo easy_install pip
or in case of Python 2.7:
sudo easy_install-2.7 pip
Debian/Ubuntu systems: Say hello to apt-get
For Debian/Ubuntu folks, installing pip is a breeze with apt-get
:
sudo apt-get update
sudo apt-get install python3-pip
Missing easy_install
? Here's how you get it:
sudo apt-get install python-setuptools
Independent realms: Virtual environments
virtualenv
is your knight in shining armor, defending against potential dependency conflicts. Bloating your global namespace is sheer heresy! We create a dedicated space for each project:
pip install virtualenv
virtualenv my_project_sandbox
source my_project_sandbox/bin/activate
Consistent across the board: pip invocation
To ensure uniform execution across environments, proceed with:
python -m pip install package_name
Python 3.x uses:
python3 -m pip install package_name
Smooth sailing: Verify pip installation
Pause and verify if pip got installed correctly. Feeling lucky? Then observe:
pip --version
or for Python 3:
pip3 --version
Script Salvation: PATH
Ensure /usr/local/bin
or the path where pip is installed is included in your PATH
:
echo $PATH
If it's missing, add it using the export command demonstrated earlier.
Symlink Savior
If pip
is in hiding despite its directory being in PATH
, wave your magic wand and create a symlink:
ln -s /path/to/pip /usr/local/bin/pip
Official docs: Your trusty sidekick
Python official documentation is a treasure trove of wisdom for your perusal, especially when it comes to installation and troubleshooting.
Community Power: Python Forums
Despite best efforts, if things go south, perform the sacred rites of invocation for our helpful community members on Python forums.
Was this article helpful?