I can't install a package with the pip or pip3 command and I can't install it from the Python Interpreter in PyCharm too. I can't tap on the '+' at the Python Interpreter in PyCharm.
I get this error:
pip command not found
Here is what you can try.
Lets check python installation.
C:\Users\User>python --version
Python 3.10.5
C:\Users\User>
If you get the version as 3.x, then we are good, else goto your python installation directory and copy its path and then add it to your environment variable PATH.
Check PIP available or not.
C:\Users\User>pip --version
pip 22.3 from C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\pip (python 3.10)
C:\Users\User>
if above didn't work then add pip path to PATH environment variable which would be something similar to above output.
Now we are ready to install any package
Just do pip install package-name
for testing, you can try:
pip install numpy
If it still throws error, try below one
python -m pip install numpy
if it still throws error, then you might need to clean your python installation.
3 commands
sudo apt update
sudo apt install python3-pip
pip3 install <package_name>
or maybe
sudo apt install <package_name> -y
It looks like you don't have pip installed on $PATH. The following command will run pip without any adjustments to $PATH:
python3 -m pip install <some_module>
Pay attention to the -m, this stands for modules and runs the pip program inside the python3 interpreter (I don't know exact definition here, if anyone wishes to correct me I will update the answer)
However, if this doesn't work then you may not have pip installed, and can be installed by running:
python3 -m ensurepip --upgrade
Then, reload your shell via the following (replace bash with your shell):
exec bash
Running pip --version should now work
pip used to work fine until recently. First I was trying to install a pip-package using
pip install -e [some-git-link]
and I get the error
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/home/me/.local/lib/python2.7/site-packages/pip-19.0.1.dist-info/METADATA'
I then cd'ed into site-packages and the folder is empty. Indeed, I have pip installed in dis-packages and its version is 18.1, not 19.0!
I tried to update pip through
pip install -U pip
but I get the same error.
Typing
pip --version
I get
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/init.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
warnings.warn(warning, RequestsDependencyWarning)
pip 18.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
so it seems that pip 18.1 is installed. Indeed, if I try
sudo apt-get install python-pip
I get
python-pip is already the newest version (8.1.1-2ubuntu0.4).
0 upgraded, 0 newly installed, 0 to remove and 62 not upgraded.
I was wondering if all these problems were coming from the warning on the cryptography, and so I tried to do
sudo pip install --upgrade cryptography
but obviously I go back to the same Environment Error.
Thou shalt not use sudo with pip. Using sudo with pip is asking for trouble. When you do that you are having pip and your OS's package manager get into a fight. When they fight no one wins, least of all your Python installation and personal sanity. I know countless tutorials tell you to sudo pip install, but they are not your friends. The only safe and reliable way to maintain a functional Python installation is to let your OS's package manager manage what it wants to manage and either use pip install --user or virtual environments (using either virtualenv or optionally python -m venv if you're on Python 3).
I really can't stress enough that you will constantly be running into little weird things (and occasional catastrophic problems) within your Python installation if you persistently sudo install things. Learn to love virtual environments! You can even modify your shell's PATH so that things you install in an environment are available as commands (which is commonly why people think they need sudo pip install).
You could test to update PythonOpenSSL :
$ sudo python -m easy_install --upgrade pyOpenSSL
If not Ok, please do :
$ sudo pip install --upgrade cryptography
But error with : $ sudo pip
So do after :
$ sudo python -m easy_install --upgrade pyOpenSSL
Have Fun,
Johan MRe
I was getting this error trying to install packages while building a Docker image (with python:3.8 as base). Upgrading pyOpenSSL as #Johan MRe suggested solved it for me.
RUN python3 -m easy_install --upgrade pyOpenSSL
How to deal with "Could not install packages due to an EnvironmentError" when upgrade pip
First run command line in Administration mode both window and OS:
Next,
For windows: use this command to upgrade pip
python -m pip install --user --upgrade pip
For MacOS:
sudo python -m pip install --user --upgrade pip
I am trying to create another virtual environment (I already installed one using the typical instructions found here: http://docs.python-guide.org/en/latest/dev/virtualenvs/) so I run:
$ virtualenv experimental
-> The program 'virtualenv' is currently not installed. You can install it by typing: sudo apt install virtualenv
I checked to see if perhaps the program needed to be updated:
$ pip install virtualenv --upgrade
-> Requirement already up-to-date: virtualenv in /home/uniside/.local/lib/python2.7/site-packages
Any ideas about what is going on here?
Use sudo. Currently it's being install in your local directory.
sudo pip install virtualenv
The answer by #khrm didn't worked for me.
I was able to do this with :
sudo apt install virtualenv
I had problems activating my virtualenv projects with Ubuntu's system version, so I just use pip's virtualenv. Works with python2 as well:
$ pip3 install virtualenv
Just call virutalenv via python3 -m:
$ python3 -m virtualenv --help
Usage: virtualenv.py [OPTIONS] DEST_DIR
I have a CentOS 6.4 which the default python version is 2.6.
I want to run a virtualenv at python 2.7, so first I try to install python 2.7.
yum install python27
Then I run
virtualenv -p /usr/bin/python2.7 ./venv
Then the output shows that it try to get setuptools from pypi, but my environment can not reach pypi.python.org. I have update the ~/.pip/pip.conf to use a available local source but the virtualenv still get pip from the pypi.python.org. This is one of the things I get confused.
I check the /usr/lib/python2.7/, the site-packages is empty while /usr/lib/python2.6/ is not. So When I use python 2.7, it has nothing available. When I use the default python, it has pip tools installed, it does not need to get it from pypi.python.org.
How can I install pip for python 2.7 individually?
Previous I install pip by
yum install python-setuptools
yum install python-pip
The second question, how to install pip for python2.7 individually can be solved as the following:
Download python source code of the specific version and install it at /usr/local
wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
tar xf Python-2.7.6.tar.xz
cd Python-2.7.6
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make && make altinstall
Then install setuptools and pip
Install easy_install (prepare ez_setup.py beforehand)
python2.7 ez_setup.py
Install pip
easy_install-2.7 pip
easy_intall-2.7 pip need to visit the internet, in my environment I get the pip source file and use "python2.7 setup.py install".
pip2.7 install [packagename]
In my environment I update .pip/pip.conf to use an internal pip source.
(code above take python 2.7 as an example)
To see the details you can check the following url:
http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/
The first question, when creating a new virtual environment, virtualenv will install setuptools for this environment. If python version is not assigned, it use the system default python and default pip. If pip is not find, then try to get it from pypi.python.org.
In my environment, after python2.7 and pip2.7 installed, when trying to create a new virtualenv, it still get pip from pypi.python.org, I guess that virtualenv does not find the relation between python2.7 and pip2.7.
If you can visit pypi.python.org, that is fine.
If you are at an internal environment that can not visit pypi.python.org, virtualenv provides -extra-search-dir and --never-download command. So you can prepare the setuptools beforehand, copy it from U-disk,using scp, or other solutions.
Move setuptools-0.6c11-py2.7.egg to /usr/local/bin.
Finally we can use virtualenv by
virtualenv -p /usr/local/bin/python2.7 --extra-search-dir /usr/local/bin/ --never-download venv
I downloaded pip and ran python setup.py install and everything worked just fine. The very next step in the tutorial is to run pip install <lib you want> but before it even tries to find anything online I get an error "bash: pip: command not found".
This is on Mac OS X. I'm assuming there's some kind of path setting that was not set correctly when I ran setup.py. How can I investigate further? What do I need to check to get a better idea of the exact cause of the problem?
EDIT: I also tried installing Python 2.7 for Mac in the hopes that the friendly install process would do any housekeeping like editing PATH and whatever else needs to happen for everything to work according to the tutorials, but this didn't work. After installing, running 'python' still ran Python 2.6 and PATH was not updated.
Why not just do sudo easy_install pip or if this is for python 2.6 sudo easy_install-2.6 pip?
This installs pip using the default python package installer system and saves you the hassle of manual set-up all at the same time.
This will allow you to then run the pip command for python package installation as it will be installed with the system python. I also recommend once you have pip using the virtualenv package and pattern. :)
2020 Update:
For current Debian/Ubuntu, use
apt-get install python3-pip
to install pip3.
Old 2013 answer (easy_install is now deprecated):
Use setuptools to install pip: sudo easy_install pip
(I know the above part of my answer is redundant with klobucar's, but I can't add comments yet), so here's an answer with a solution to sudo: easy_install: command not found on Debian/Ubuntu: sudo apt-get install python-setuptools
Also, for python3, use easy_install3 and python3-setuptools.
For Python 3, use apt-get install python3-pip.
First of all: try pip3 instead of pip. Example:
pip3 --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
pip3 should be installed automatically together with Python3.x. The documentation hasn't been updated, so simply replace pip by pip3 in the instructions, when installing Flask for example.
Now, if this doesn't work, you might have to install pip separately.
Update: A more reliable modern way to access the right pip install for the right python install is to use the syntax python -m pip.
Original Answer
pip would install itself into the bin of your python installation location. It also should create a symlink to some more common location like /usr/local/bin/pip
You can either edit your ~/.profile and update your PATH to include /Library/Frameworks/Python.framework/Versions/2.6/bin, or you could create a symlink to it in a place that you know is in your path.
If you do: echo $PATH, you should see the paths currently being searched. If /usr/local/bin is in your PATH, you can do:
ln -s /Library/Frameworks/Python.framework/Versions/2.6/bin/pip /usr/local/bin
I would opt for adding the python bin to your $PATH variable.
I encountered this problem having downloaded python 3.x.x and trying to install awscli - pip: command not found.
Whilst following the instructions for downloading the AWS client, I changed
pip install awscli
to
pip3 install awscli
which ran the correct version.
I've made an alias on my machine to run python3 whilst typing python, which would normally run the system version 2.7. I'm not sure this is a good idea now. I think I'll just type in the commands as they intended them to be.
Check out How to Install Pip article for more information.
As of 2019,
Download get-pip.py provided by https://pip.pypa.io using the following command:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Run get-pip.py using the following command:
sudo python get-pip.py
After you done installing, run this command to check if pip is installed.
pip --version
Remove get-pip.py file after installing pip.
rm get-pip.py
Install Python latest version as given here
It has many download links like numpy and scipy
Then go to terminal and enter following command:-
sudo easy_install pip
For Python install packages check this
Requirements for Installing Packages
This section describes the steps to follow before installing other Python packages.
Install pip, setuptools, and wheel If you have Python 2 >=2.7.9 or
Python 3 >=3.4 installed from python.org, you will already have pip
and setuptools, but will need to upgrade to the latest version:
On Linux or OS X:
pip install -U pip setuptools On Windows:
python -m pip install -U pip setuptools If you’re using a Python
install on Linux that’s managed by the system package manager (e.g
“yum”, “apt-get” etc…), and you want to use the system package manager
to install or upgrade pip, then see Installing pip/setuptools/wheel
with Linux Package Managers
Otherwise:
Securely Download get-pip.py 1
Run python get-pip.py. 2 This will install or upgrade pip.
Additionally, it will install setuptools and wheel if they’re not
installed already.
I spent ages going through all the answers on this page but found the one that worked for me in the comments of the OP question by s-walsh
The answer is to use pip3:
$ pip3 install <name-of-install>
Installing using apt-get installs a system wide pip, not just a local one for your user. Try this command to get pip running on your system ...
$ sudo apt-get install python-pip python-dev build-essential
Then pip will be installed without any issues and you will be able to use "sudo pip...".
Most of the methods to install PIP are deprecated. Here is the latest (2019) solution. Please download get-pip script
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Run the script
sudo python get-pip.py
Latest update 2021.
In Ubuntu 20 64bit works perfectly
Installation of python3
sudo apt install python3
Pip Installation
sudo apt install python3-pip
Add following alias in $HOME/.bash_aliases in some cases file may be hidden.
alias pip="/usr/bin/python3 -m pip "
Refresh current terminal session.
. ~/.profile
check pip usage: pip
Install a package: pip install {{package_name}}
extra info
to get Home path
echo $HOME
you will get your home path.
To solve:
Add this line to ~/.bash_profile:
export PATH="/usr/local/bin:$PATH"
In a terminal window, run
source ~/.bash_profile
It might be the root permission. I tried exit root login, and use
sudo su -l root
pip <command>
install Homebrew, open Terminal or your favorite OSX terminal emulator and run
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
insert the Homebrew directory at the top of your PATH environment variable. You can do this by adding the following line at the bottom of your ~/.profile file
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
Now, we can install Python 2.7:
$ brew install python
Get pip repository:
$ git clone https://github.com/pypa/pip
install pip:
$sudo easy_install pip
python install it by default but if not install you can install it manual use following cmd (for linux only )
for python3 :
sudo apt install python3-pip
for python2
sudo apt install python-pip
hope its help.
If you are running Python 3.5, run the following terminal command:
sudo pip3 install -U nltk
Any other pip commands in terminal would be similar:
pip3 install --upgrade pip
sudo pip3 install -U numpy ::
It solved my problem by using
sudo easy_install pip
Solved this by upgrading python 3 brew upgrade python:
Now i can just do:
pip3 install <package>
==> python
Python has been installed as
/usr/local/bin/python3
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have
Based on this stackoverflow answer and some of the answers on this thread, I have created an alias in the rc file:
alias pip="python3 -m pip"
There seem to be many different answers to this question but this seems to be the best-practice approach.
Avoiding sudo:
python <(curl https://bootstrap.pypa.io/get-pip.py) --user
echo 'export "PATH=$HOME/Library/Python/2.7/bin:$PATH"' >> ~/.bash_profile
From:
http://www.pip-command-not-found.com
CentOS 7 users can just use:
yum install python-pip
Also recommend using virtualenv if you're using pip. It can be added in the same way:
yum install python-virtualenv
assuming you have internet see:
https://pip.pypa.io/en/stable/installing/
basically run:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
and
python get-pip.py
Try using this. Instead of zmq, we can use any package instead of zmq.
sudo apt-get install python3-pip
sudo apt-get update
python3 -m pip install zmq
I was was not able to install this zmq package in my docker image because of the same issue i was getting. So tried this as another way to install and it worked fine for me.
To overcome the issue bash: pip: command not found in Mac
Found two versions on Mac 1 is 2.7 and the other is 3.7
when I say sudo easy_install pip, pip got installed under 2.7
when I say sudo easy_install-3.7 pip, pip got installed under 3.7
But, whenever I would require to do pip install , I wanted to install the package under python3.7, so I have set an alias (alias pip=pip3) in .bash_profile.
so now, whenever I do pip install <package_name>, it gets installed under python3.7
(Context: My OS is Amazon linux using AWS. It seems similar to RedHat but it's stripped down a bit, it seems.)
Exit the shell, then open a new shell. The pip command now works.
That's what solved the problem at this location.
You might want to know as well: The pip commands to install software then needed to be written like this example (jupyter for example) to work correctly on my system:
pip install jupyter --user
Specifically, note the lack of sudo, and the presence of --user
Would be real nice if pip docs had said anything about all this, but that would take typing in more characters I guess.
Not sure why this wasnt mentioned before, but the only thing that worked for me (on my NVIDIA Xavier) was:
sudo apt-get install python3-pip
(or sudo apt-get install python-pip for python 2)
apt -y -qq install python3 python3-pip
ln -s /usr/bin/python3 /usr/bin/python
ln -s /usr/bin/pip3 /usr/bin/pip
What I did to overcome this was sudo apt install python-pip.
It turned out my virtual machine did not have pip installed yet. It's conceivable that other people could have this scenario too.
The updated command for installing pip3 is :
sudo apt-get install python3-pip
The problem seems that your python version and the library yoıu want to install is not matching versionally. Ex: If Django is Django3 and your python version is 2.7, you may get this error.
"After installing is running 'python' still ran Python 2.6 and PATH was not updated."
1- Install latest version of Python
2- Change your PATH manually as python38 and compare them.
3- Try to reinstall.
I solved this problem as replacing PATH manually with the latest version of Python.
As for Windows: ;C:\python38\Scripts