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
But when i run command sudo apt-get install python3-pip. It is installed but inot as python3.6. It is installed in python3.5.I have also specified the version in command i.e sudo apt-get install python3.6-pip.But it gives me an error.
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python3.6-pip
E: Couldn't find any package by glob 'python3.6-pip'
E: Couldn't find any package by regex 'python3.6-pip'
You can install python packages using python3.6 -m pip install [Package_to_install] straight away.
I use PipEnv for working in different environments with different python versions.
the usage would be something like pipenv --python 3.X and it will install that version of python if its not installed.
It also makes things really helpful if you are collaborating with other developers, because it creates a PipFile (alt to requirements.pip) which will contain the version of python used for the project so all developers will use the same version of python on a project without doing any prep work.
If you don't want to use pipenv you can use pip3.5 or create a python3.5 environment like virtualenv [NAME] --python=/usr/lib/python3.5 and then install the package using pip install somepackage
This will help you fix the above problem
You need to add following personal package repository:
sudo add-apt-repository ppa:deadsnakes/ppa
Check for updates
sudo apt-get update
install python using following command
sudo apt-get install python3.6
It was easy. I just changed my default python3 version:
sudo gedit ~/.bashrc alias python3="python3.6"
Now I can install the packages using python3.6 with
-m pip install 'packagenae'
I got a message in my terminal while install a software : You are using pip version 8.1.1, however version 10.0.0 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
So I upgraded pip version: $ pip install --upgrade pip
Now I am getting this error:
~$ pip install ipython
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError: cannot import name main
TL;DR
The 'ideal' solution (Ubuntu/Debian way):
$ python -m pip uninstall pip to uninstall the new pip 10 and retain your Ubuntu/Debian-provided patched pip 8. For a system-wide installation of modules use apt wherever possible (unless you are in a virtualenv), more on it below. In older Ubuntu/Debian versions, always add --user flag when using pip outside of virtualenvs (installs into ~/.local/, default in python-pip and python3-pip since 2016).
If you still want to use the new pip 10 exclusively, there are 3 quick workarounds:
simply re-open a new bash session (a new terminal tab, or type bash) - and pip 10 becomes available (see pip -V). debian's pip 8 remains installed but is broken; or
$ hash -d pip && pip -V to refresh pip pathname in the $PATH. debian's pip 8 remains installed but is broken; or
$ sudo apt remove python-pip && hash -d pip (for Python 3 it's python3-pip) -- to uninstall debian's pip 8 completely, in favor of your new pip 10.
Note: You will always need to add --user flag to non-debian-provided pip 10, unless you are in a virtualenv! Your use of pip 10 system-wide, outside of virtualenv, is not really supported by Ubuntu/Debian. Never sudo pip!
Details:
https://github.com/pypa/pip/issues/5221#issuecomment-382069604
https://github.com/pypa/pip/issues/5240#issuecomment-381673100
Ubuntu 16.04 with Python 2.7.12
Introduction:
Ironically, despite being suggested by pip itself to do such an upgrade via the pip install --upgrade pip command explicitely in the terminal (ugh!), upgrading it is not recommended in prepackaged GNU/Linux distributions. Ubuntu generally expects using APT package manager for any system-wide Python module updates/installs (including of pip itself), for example:
$ sudo apt-get update (resync Ubuntu package index files from sources)
$ apt-cache search <python-package-name> (full text-search on all available packages)
$ apt-cache show <python-package-name> (displays the package description)
$ sudo apt-get install python-numpy python-scipy python-matplotlib (easily installs heavy modules for data science, resolving all system dependencies automatically)
$ sudo apt-get install ipython (installs the IPython-notebook you were looking for)
$ sudo apt-get install python-pip (installs/upgrades pip to the latest version available in Ubuntu repository – usually slightly behind pypi.org, but it doesn't matter)
If you ever have to use pip install command on Ubuntu/Debian instead of apt-get install, please make sure it runs isolated and does not change the default system-wide Python packages (never use sudo with pip) – more on this below.
ImportError: cannot import name main
The error is caused by the pip install --upgrade pip command: that installs the latest pip version 10 alongside Ubuntu's default pip version from python-pip debian package from the OS distribution (the system Python installation), completely bypassing Ubuntu apt subsystem. It breaks the Ubuntu's default pip: the debian-patched launcher script from python-pip (system-installed to /usr/bin/pip*) tries to do import main() from your newly installed pip 10 library, but with a different import path, so it fails.
This error is discussed in more detail in a developer thread of the pip issue tracker, including a few proposed solutions, such as:
The $ hash -d pip command: when hash is invoked, the full pathname of pip is determined by searching the directories in $PATH and remembered. Any previously-remembered pathname is discarded. The -d option causes the shell to "forget" the remembered location of the given package name; or
Similarly, you can simply re-open a new bash session (a new terminal tab) to refresh pip pathname in $PATH; or
You could just use pip2 command (or pip3 for Python 3) instead of pip to invoke the older system-installed pip script /usr/bin/pip2 , whereas any pip launcher script located in $HOME/.local/bin dir (pip, pip2, pip2.7) will start your new user-installed pip 10 version;
You can also use the versioned Python commands in combination with the -m switch to run the appropriate copy of pip, for example:
$ python2 -m pip install --user SomePackage # default Python 2
$ python2.7 -m pip install --user SomePackage # specifically Python 2.7
That is handy if you have several versions of Python and need an extension from PyPI for a specific Python version. The --user switch is only required when pip is used outside of virtualenv.
Or, uninstall one of the two pips – either user-installed or system-installed – to resolve the conflict:
$ python -m pip uninstall pip – to remove your manually-installed pip in favour of the previously installed Ubuntu-shipped version from python-pip debian package (python3-pip for Python 3); it is slightly older, but it finds and installs latest modules from PyPI just fine, and has a working pip command in the $PATH by default; or
$ sudo apt-get remove python-pip – to uninstall Ubuntu-provided pip in favour of your latest pip 10; if it is not accessible via the short pip command, just add your $HOME/.local/bin directory to your $PATH environment variable to use pip command (see above).
Note: Ubuntu 16.04 pip v8.1.1 and the latest pip v10.0.1 produce exactly the same PyPI index search results and can pull the same module versions;
Finally, you could ignore both pips altogether in favor of APT, and install Python packages system-wide from Ubuntu repo with:
$ apt search <python-package> # e.g. python-pandas
$ apt show <python-package> # e.g. python-flask
$ sudo apt install <python-package>
Packages prefixed with python- are for Python 2; with python3- are for Python 3.
Installation via apt-get may be what you need, in fact, python-packages from Ubuntu repository are preferred whenever possible, particularly in case of heavy system dependencies or when used system-wide. Of course, the amount of Python packages in Ubuntu repository (few thousand!) is relatively smaller compared to PyPI (and have only one version of them), because any OS repository is lagging slightly behind PyPI versions. But the upside of APT is that all the Ubuntu-provided packages underwent integration testing within Ubuntu, plus apt-get quickly resolves heavy dependencies like C extensions automatically. You will always get any required system libraries as part of the apt install, but with pip you have no such guarantees.
APT may not be an option, however, if you really need the latest (or certain older) package version, or when it can only be found at PyPI, or when modules need to be isolated; then pip is indeed more appropriate tool. If you use pip install command on Ubuntu instead of apt-get install, please ensure that it runs in an isolated virtual development environment, such as with virtualenv (sudo apt-get install python-virtualenv), or a built-in venv module (available in python3 only), or at a per-user level (pip install --user command option), but not system-wide (never sudo pip!).
Note: Using sudo pip command (with root access) should be avoided, because it interferes with the operation of the system package manager (apt) and may affect Ubuntu OS components when a system-used python module is unexpectedly upgraded, particularly by dependencies on another pip package. It is advised to never use Pip to change your system-wide Python packages, as these are managed by apt-get on Ubuntu.
I implemmented #catalinpopescu response from ImportError: cannot import name main when running pip --version command in windows7 32 bit
Find pip's path:
$ which pip
Modify file (choose your favorite editor):
$ sudo nano `which pip`
Then modify lines #catalinpopescu said:
Comment/replace lines:
from pip import main
sys.exit(main())
to:
from pip import __main__
sys.exit(__main__._main())
Immediately I upgrade to Pip Version 10.0.1, which appears it hasn't have this error.
try to upgrade the system pip
sudo pip install --upgrade pip
pip install --upgrade pip
this may be useful
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