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
Related
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
I'm trying to install pip3, but I'm not having any luck. Also, I tried sudo install and it did not work. How could I install pip3 on my Mac?
sudo easy_install pip3
Password:
Searching for pip3
Reading https://pypi.python.org/simple/pip3/
Couldn't find index page for 'pip3' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
No local packages or download links found for pip3
error: Could not find suitable distribution for Requirement.parse('pip3')
UPDATED - Homebrew version after 1.5
According to the official Homebrew page:
On 1st March 2018 the python formula will be upgraded to Python 3.x and a python#2 formula will be added for installing Python 2.7 (although this will be keg-only so neither python nor python2 will be added to the PATH by default without a manual brew link --force). We will maintain python2, python3 and python#3 aliases.
So to install Python 3, run the following command:
brew install python3
Then, the pip or pip3 is installed automatically, and you can install any package by pip install <package>.
The older version of Homebrew
Not only brew install python3 but also brew postinstall python3
So you must run:
brew install python3
brew postinstall python3
Note that you should check the console, as it might get you errors and in that case, the pip3 is not installed.
You could use Homebrew.
Then just run:
brew install python3
I solved the same problem with these commands:
curl -O https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
For me brew postinstall python3 didn't work. I found this solution on the GitHub Homebrew issues page:
$ brew rm python
$ rm -rf /usr/local/opt/python
$ brew cleanup
$ brew install python3
Python 3 was working successfully, but without pip3. I tried advice from Stack Overflow, Quora and others (numerous installs and uninstalls).
Python 3 was always fine, but without pip3. Finally I downloaded Python3 from:
https://www.python.org/downloads/
By simple mouse clicks and everything (Python 3 + pip3), it is working fine now.
To install or upgrade pip, download get-pip.py from the official site. Then run the following command:
sudo python get-pip.py
and it will install pip for your python version which runs the script.
Similar to Oksana but add python3
$ brew rm python
$ brew rm python3
$ rm -rf /usr/local/opt/python
$ rm -rf /usr/local/opt/python3
$ brew prune
$ brew install python3
$ brew postinstall python3
Seem now work for pip3 under mac os x 10.13.3 Xcode 9.2
I ran the below where <user>:<group> matched the other <user>:<group> for other files in the /usr/local/lib/python3.7/site-packages/ directory:
sudo chown -R <user>:<group> /usr/local/lib/python3.7/site-packages/pip*
brew postinstall python3
I also encountered the same problem but brew install python3 does not work properly to install pip3.
brre will throw the warning The post-install step did not complete successfully.
It has to do with homebrew does not have permission to /usr/local
Create the directory if not exist
sudo mkdir lib
sudo mkdir Frameworks
Give the permissions inside /usr/local to homebrew so it can access them:
sudo chown -R $(whoami) $(brew --prefix)/*
Now ostinstall python3
brew postinstall python3
This will give you a successful installation
After upgrading to macOS v10.15 (Catalina), and upgrading all my vEnv modules, pip3 stopped working (gave error: "TypeError: 'module' object is not callable").
I found question 58386953 which led to here and solution.
Exit from the vEnv (I started a fresh shell)
sudo python3 -m pip uninstall pip (this is necessary, but it did not fix problem, because it removed the base Python pip, but it didn't touch my vEnv pip)
sudo easy_install pip (reinstalling pip in base Python, not in vEnv)
cd to your vEnv/bin and type "source activate" to get into vEnv
rm pip pip3 pip3.6 (it seems to be the only way to get rid of the bogus pip's in vEnv)
Now pip is gone from vEnv, and we can use the one in the base Python (I wasn't able to successfully install pip into vEnv after deleting)
Installing Pip3
Follow this link to download pip3 on your computer
Follow the instructions on the page and then after successfully downloading Pip3, run python3 get-pip.py in your terminal
This will install pip3 into your laptop and then you can check the installation of pip3 by running which pip3 in your terminal.
Now simply do pip3 install <package>
If you're using Python 3, just execute python3 get-pip.py . It is just a simple command.
I wanted to deploy my Python app on Amazon Linux AMI 2015.09.1, which has Python2.7 (default) and pip (6.1.1). Then, I upgraded the pip using the command:
sudo pip install -U pip
However, it seemed broken, and showed the message when I tried to install packages:
pkg_resources.DistributionNotFound: pip==6.1.1
I found out that pip remove the previous files located in /usr/bin/, and installed the new one in /usr/local/bin. Thus, I tried to specify the location by using the command:
sudo pip install -U --install-option="--prefix='/usr/bin'" pip
Nevertheless, it still installed the new one in /usr/local/bin. In addition to that, pip could not work well with sudo although it successfully installed. The error message :
sudo: pip2.7: command not found
Is there a way to properly manage pip?
Try:
sudo which pip
This may reveal something like 'no pip in ($PATH)'.
If that is the case, you can then do:
which pip
Which will give you a path like /usr/local/bin/pip.
Copy + paste the path to pip to the sbin folder by running: sudo cp /usr/local/bin/pip /usr/sbin/
This will allow you to run sudo pip without any errors.
Struggled with this for a while. Here's what I've found:
ec2_user finds the pip executable, but has a module import error due to other having no read/execute permissions on the pip folders in the /usr/local/lib/python2.7/site-packages folder. This is actually okay, since in most cases, pip installs fail when not run as root anyway.
sudo cannot find pip.
Entering root with sudo su - allows pip to be run without issue.
The reason sudo pip stops working after the upgrade, is because the executable (or symbolic link) is removed from /usr/bin. However, what remains is a file called pip-27, which contains the following:
#!/usr/bin/python2.7
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==6.1.1','console_scripts','pip2.7'
__requires__ = 'pip==6.1.1'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('pip==6.1.1', 'console_scripts', 'pip2.7')()
)
So, that's where our error comes from, as the upgrade clearly doesn't clean this file up. Not entirely clear on where the name translation from pip to pip-2.7 occurs.
As mentioned in another answer, pip now exists in /usr/local/bin after the upgrade, which is no longer in the sudo secure path. You can add this path to the secure_path variable by running sudo visudo. Another alternative, if you'd prefer to not add that path to your secure_path is to make a symbolic link to the new pip executable in /usr/bin.
The problem is partly answered by your question. The Amazon AMI doesn't consider /usr/local/bin to be part of the root account's PATH. You can fix this by updating the root account's ~/.bashrc to include it.
Something like this...
export PATH=$PATH:/usr/local/bin
After struggling with this for hours and reading comments
which pip gave /usr/bin/pip , but the actual pip was located at /usr/local/bin/pip due to pip upgrade and clean up was not complete
So removing the pip in /usr/bin/
sudo rm /usr/bin/pip
and also adding the new pip to your export path
vim ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/bin
exit terminal, and login back
which pip should give /usr/local/bin/pip
pip install --upgrade pip
This works for me
sudo /usr/local/bin/pip install --upgrade pip
To add to angelokh
sudo `which pip` install --upgrade pip
I think the best strategy in this case is to manage pip is as part of a virtual environment using virtualenv rather than messing with the system-level version.
If you're OK with that, here's the basic idea:
Install the version of virtualenv packaged with the version of pip you are looking to upgrade to to the system-level pip (e.g. virtualenv==15.1.0 comes with pip==9.0.1):
$ sudo pip install -U virtualenv==15.1.0
You are using pip version 6.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting virtualenv==15.1.0
Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB)
100% |████████████████████████████████| 1.8MB 135kB/s
Installing collected packages: virtualenv
Found existing installation: virtualenv 12.0.7
Uninstalling virtualenv-12.0.7:
Successfully uninstalled virtualenv-12.0.7
Successfully installed virtualenv-15.1.0
I used the virtualenv release notes to find out which version of pip corresponds to which version of virtualenv.
Create the virtual environment:
$ virtualenv myenv
New python executable in /home/ec2-user/myenv/bin/python2.7
Also creating executable in /home/ec2-user/myenv/bin/python
Installing setuptools, pip, wheel...done.
Activate the virtual environment and confirm the version and location of the upgraded pip:
$ source myenv/bin/activate
(myenv) $ pip -V
pip 9.0.1 from /home/ec2-user/myenv/local/lib/python2.7/dist-packages (python 2.7)
(myenv) $ which pip
~/myenv/bin/pip
This should allow you to install packages to this virtualenv using the pip version of your choice, without the need for sudo.
I think you've didn't installed the pythonXX-pip package.
I've upgraded mine straight to Python3.4, these commands works for me.
sudo su
yum install python34
yum install python34-pip
I have both python2.7 and python3.2 installed in Ubuntu 12.04.
The symbolic link python links to python2.7.
When I type:
sudo pip install package-name
It will default install python2 version of package-name.
Some package supports both python2 and python3.
How to install python3 version of package-name via pip?
Ubuntu 12.10+ and Fedora 13+ have a package called python3-pip which will install pip-3.2 (or pip-3.3, pip-3.4 or pip3 for newer versions) without needing this jumping through hoops.
I came across this and fixed this without needing the likes of wget or virtualenvs (assuming Ubuntu 12.04):
Install package python3-setuptools: run sudo aptitude install python3-setuptools, this will give you the command easy_install3.
Install pip using Python 3's setuptools: run sudo easy_install3 pip, this will give you the command pip-3.2 like kev's solution.
Install your PyPI packages: run sudo pip-3.2 install <package> (installing python packages into your base system requires root, of course).
…
Profit!
You may want to build a virtualenv of python3, then install packages of python3 after activating the virtualenv. So your system won't be messed up :)
This could be something like:
virtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
pip install package-name
Short Answer
sudo apt-get install python3-pip
sudo pip3 install MODULE_NAME
Source: Shashank Bharadwaj's comment
Long Answer
The short answer applies only on newer systems. On some versions of Ubuntu the command is pip-3.2:
sudo pip-3.2 install MODULE_NAME
If it doesn't work, this method should work for any Linux distro and supported version:
sudo apt-get install curl
curl https://bootstrap.pypa.io/get-pip.py | sudo python3
sudo pip3 install MODULE_NAME
If you don't have curl, use wget. If you don't have sudo, switch to root. If pip3 symlink does not exists, check for something like pip-3.X
Much python packages require also the dev package, so install it too:
sudo apt-get install python3-dev
Sources:
python installing packages with pip
Pip latest install
Check also Tobu's answer if you want an even more upgraded version of Python.
I want to add that using a virtual environment is usually the preferred way to develop a python application, so #felixyan answer is probably the best in an ideal world. But if you really want to install that package globally, or if need to test / use it frequently without activating a virtual environment, I suppose installing it as a global package is the way to go.
Well, on ubuntu 13.10/14.04, things are a little different.
Install
$ sudo apt-get install python3-pip
Install packages
$ sudo pip3 install packagename
NOT pip-3.3 install
The easiest way to install latest pip2/pip3 and corresponding packages:
curl https://bootstrap.pypa.io/get-pip.py | python2
pip2 install package-name
curl https://bootstrap.pypa.io/get-pip.py | python3
pip3 install package-name
Note: please run these commands as root
I had the same problem while trying to install pylab, and I have found this link
So what I have done to install pylab within Python 3 is:
python3 -m pip install SomePackage
It has worked properly, and as you can see in the link you can do this for every Python version you have, so I guess this solves your problem.
Old question, but none of the answers satisfies me. One of my systems is running Ubuntu 12.04 LTS and for some reason there's no package python3-pip or python-pip for Python 3. So here is what I've done (all commands were executed as root):
Install setuptools for Python3 in case you haven't.
apt-get install python3-setuptools
or
aptitude install python3-setuptools
With Python 2.4+ you can invoke easy_install with specific Python version by using python -m easy_install. So pip for Python 3 could be installed by:
python3 -m easy_install pip
That's it, you got pip for Python 3. Now just invoke pip with the specific version of Python to install package for Python 3. For example, with Python 3.2 installed on my system, I used:
pip-3.2 install [package]
If you have pip installed in both pythons, and both are in your path, just use:
$ pip-2.7 install PACKAGENAME
$ pip-3.2 install PACKAGENAME
References:
http://www.pip-installer.org/docs/pip/en/0.8.3/news.html#id4
https://github.com/pypa/pip/issues/200
This is a duplicate of question #2812520
If your system has python2 as default, use below command to install packages to python3
$ python3 -m pip install <package-name>
Easy enough:
sudo aptitude install python3-pip
pip-3.2 install --user pkg
If you want Python 3.3, which isn't the default as of Ubuntu 12.10:
sudo aptitude install python3-pip python3.3
python3.3 -m pip.runner install --user pkg
You can alternatively just run pip3 install packagename instead of pip,
Firstly, you need to install pip for the Python 3 installation that you want. Then you run that pip to install packages for that Python version.
Since you have both pip and python 3 in /usr/bin, I assume they are both installed with a package manager of some sort. That package manager should also have a Python 3 pip. That's the one you should install.
Felix' recommendation of virtualenv is a good one. If you are only testing, or you are doing development, then you shouldn't install the package in the system python. Using virtualenv, or even building your own Pythons for development, is better in those cases.
But if you actually do want to install this package in the system python, installing pip for Python 3 is the way to go.
Although the question relates to Ubuntu, let me contribute by saying that I'm on Mac and my python command defaults to Python 2.7.5. I have Python 3 as well, accessible via python3, so knowing the pip package origin, I just downloaded it and issued sudo python3 setup.py install against it and, surely enough, only Python 3 has now this module inside its site packages. Hope this helps a wandering Mac-stranger.
Execute the pip binary directly.
First locate the version of PIP you want.
jon-mint python3.3 # whereis ip
ip: /bin/ip /sbin/ip /usr/share/man/man8/ip.8.gz /usr/share/man/man7/ip.7.gz
Then execute.
jon-mint python3.3 # pip3.3 install pexpect
Downloading/unpacking pexpect
Downloading pexpect-3.2.tar.gz (131kB): 131kB downloaded
Running setup.py (path:/tmp/pip_build_root/pexpect/setup.py) egg_info for package pexpect
Installing collected packages: pexpect
Running setup.py install for pexpect
Successfully installed pexpect
Cleaning up...
You should install ALL dependencies:
sudo apt-get install build-essential python3-dev python3-setuptools python3-numpy python3-scipy libatlas-dev libatlas3gf-base
Install pip3(if you have installed, please look step 3):
sudo apt-get install python3-pip
Iinstall scikit-learn by pip3
pip3 install -U scikit-learn
Open your terminal and entry python3 environment, type import sklearn to check it.
To install pip for python3 use should use pip3 instead of pip.
To install python in ubuntu 18.08 bionic
before installing a version of python, activate virtual environment so that it won't have any problem in a future versions of python.
virtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
then install the actual python version you want.
>> sudo apt-get install python3.7
To install the required pip package in ubuntu
>> sudo apt-get install python3-pip
You Can Simply type in terminal/console .
Commands
sudo apt update
sudo apt upgrade
sudo apt install python3-pip3
pip3 install package-name
Another way to install python3 is using wget. Below are the steps for installation.
wget http://www.python.org/ftp/python/3.3.5/Python-3.3.5.tar.xz
tar xJf ./Python-3.3.5.tar.xz
cd ./Python-3.3.5
./configure --prefix=/opt/python3.3
make && sudo make install
Also,one can create an alias for the same using
echo 'alias py="/opt/python3.3/bin/python3.3"' >> ~/.bashrc
Now open a new terminal and type py and press Enter.
I want to install pip. It should support Python 3, but it requires setuptools, which is available only for Python 2.
How can I install pip with Python 3?
edit: Manual installation and use of setuptools is not the standard process anymore.
If you're running Python 2.7.9+ or Python 3.4+
Congrats, you should already have pip installed. If you do not, read onward.
If you're running a Unix-like System
You can usually install the package for pip through your package manager if your version of Python is older than 2.7.9 or 3.4, or if your system did not include it for whatever reason.
Instructions for some of the more common distros follow.
Installing on Debian (Wheezy and newer) and Ubuntu (Trusty Tahr and newer) for Python 2.x
Run the following command from a terminal:
sudo apt-get install python-pip
Installing on Debian (Wheezy and newer) and Ubuntu (Trusty Tahr and newer) for Python 3.x
Run the following command from a terminal:
sudo apt-get install python3-pip
Note:
On a fresh Debian/Ubuntu install, the package may not be found until you do:
sudo apt-get update
Installing pip on CentOS 7 for Python 2.x
On CentOS 7, you have to install setup tools first, and then use that to install pip, as there is no direct package for it.
sudo yum install python-setuptools
sudo easy_install pip
Installing pip on CentOS 7 for Python 3.x
Assuming you installed Python 3.4 from EPEL, you can install Python 3's setup tools and use it to install pip.
# First command requires you to have enabled EPEL for CentOS7
sudo yum install python34-setuptools
sudo easy_install pip
If your Unix/Linux distro doesn't have it in package repos
Install using the manual way detailed below.
The manual way
If you want to do it the manual way, the now-recommended method is to install using the get-pip.py script from pip's installation instructions.
Install pip
To install pip, securely download get-pip.py
Then run the following (which may require administrator access):
python get-pip.py
If setuptools is not already installed, get-pip.py will install setuptools for you.
I was able to install pip for python 3 on Ubuntu just by running sudo apt-get install python3-pip.
Python 3.4+ and Python 2.7.9+
Good news! Python 3.4 (released March 2014) ships with Pip. This is the best feature of any Python release. It makes the community's wealth of libraries accessible to everyone. Newbies are no longer excluded by the prohibitive difficulty of setup. In shipping with a package manager, Python joins Ruby, Nodejs, Haskell, Perl, Go--almost every other contemporary language with a majority open-source community. Thank you Python.
Of course, that doesn't mean Python packaging is problem solved. The experience remains frustrating. I discuss this at Does Python have a package/module management system?
Alas for everyone using an earlier Python. Manual instructions follow.
Python ≤ 2.7.8 and Python ≤ 3.3
Follow my detailed instructions at https://stackoverflow.com/a/12476379/284795 . Essentially
Official instructions
Per https://pip.pypa.io/en/stable/installing.html
Download get-pip.py, being careful to save it as a .py file rather than .txt. Then, run it from the command prompt.
python get-pip.py
You possibly need an administrator command prompt to do this. Follow http://technet.microsoft.com/en-us/library/cc947813(v=ws.10).aspx
For me, this installed Pip at C:\Python27\Scripts\pip.exe. Find pip.exe on your computer, then add its folder (eg. C:\Python27\Scripts) to your path (Start / Edit environment variables). Now you should be able to run pip from the command line. Try installing a package:
pip install httpie
There you go (hopefully)!
if you're using python 3.4+
just type:
python3 -m pip
For Ubuntu 12.04 or older,
sudo apt-get install python3-pip
won't work. Instead, use:
sudo apt-get install python3-setuptools ca-certificates
sudo easy_install3 pip
Update 2015-01-20:
As per https://pip.pypa.io/en/latest/installing.html the current way is:
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
I think that should work for any version
Original Answer:
wget http://python-distribute.org/distribute_setup.py
python distribute_setup.py
easy_install pip
Single Python in system
To install packages in Python always follow these steps:
If the package is for python 2.x: sudo python -m pip install [package]
If the package is for python 3.x: sudo python3 -m pip install [package]
Note: This is assuming no alias is set for python
Through this method, there will be no confusion regarding which python version is receiving the package.
Multiple Pythons/Virtual Envs
Say you have python3 ↔ python3.6 and python3.7 ↔ python3.7
To install for python3.6: sudo python3 -m pip install [package]
To instal for python3.7: sudo python3.7 -m pip install [package]
This is essentially the same method as shown previously.
Note 1
How to find which python? Do one of the following:
~ » python3 -c "import sys; print(sys.version)"
3.9.5 (default, Nov 18 2021, 16:00:48)
your python3 command spawns:
~ » python3
Python 3.9.5 (default, Nov 18 2021, 16:00:48)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Notice python 3.9.5 in the second line.
or say you are using virtual env and see where your python points to:
» which python
/home/ganesh/os/np-test/bin/python
Note 2
Change what python3 or python points to: https://askubuntu.com/questions/320996/how-to-make-python-program-command-execute-python-3
python3 -m ensurepip
I'm not sure when exactly this was introduced, but it's installed pip3 for me when it didn't already exist.
Older version of Homebrew
If you are on macOS, use homebrew.
brew install python3 # this installs python only
brew postinstall python3 # this command installs pip
Also note that you should check the console if the install finished successfully. Sometimes it doesn't (e.g. an error due to ownership), but people simply overlook the log.
UPDATED - Homebrew version after 1.5
According to the official Homebrew page:
On 1st March 2018 the python formula will be upgraded to Python 3.x and a python#2 formula will be added for installing Python 2.7 (although this will be keg-only so neither python nor python2 will be added to the PATH by default without a manual brew link --force). We will maintain python2, python3 and python#3 aliases.
So to install Python 3, run the following command:
brew install python3
Then, the pip is installed automatically, and you can install any package by pip install <package>.
If your Linux distro came with Python already installed, you should be able to install PIP using your system’s package manager. This is preferable since system-installed versions of Python do not play nicely with the get-pip.py script used on Windows and Mac.
Advanced Package Tool (Python 2.x)
sudo apt-get install python-pip
Advanced Package Tool (Python 3.x)
sudo apt-get install python3-pip
pacman Package Manager (Python 2.x)
sudo pacman -S python2-pip
pacman Package Manager (Python 3.x)
sudo pacman -S python-pip
Yum Package Manager (Python 2.x)
sudo yum upgrade python-setuptools
sudo yum install python-pip python-wheel
Yum Package Manager (Python 3.x)
sudo yum install python3 python3-wheel
Dandified Yum (Python 2.x)
sudo dnf upgrade python-setuptools
sudo dnf install python-pip python-wheel
Dandified Yum (Python 3.x)
sudo dnf install python3 python3-wheel
Zypper Package Manager (Python 2.x)
sudo zypper install python-pip python-setuptools python-wheel
Zypper Package Manager (Python 3.x)
sudo zypper install python3-pip python3-setuptools python3-wheel
This is the one-liner I copy-and-paste:
curl https://bootstrap.pypa.io/get-pip.py | python3
Alternate:
curl -L get-pip.io | python3
From Installing with get-pip.py:
To install pip, securely download get-pip.py by following this link:
get-pip.py. Alternatively, use
curl:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Then run the following command in the folder where you have downloaded
get-pip.py:
python get-pip.py
Warning: Be cautious if you are using a Python install that is managed
by your operating system or another package manager. get-pip.py does
not coordinate with those tools, and may leave your system in an
inconsistent state.
If you use several different versions of python try using virtualenv http://www.virtualenv.org/en/latest/virtualenv.html#installation
With the advantage of pip for each local environment.
Then install a local environment in the current directory by:
virtualenv -p /usr/local/bin/python3.3 ENV --verbose
Note that you specify the path to a python binary you have installed on your system.
Then there are now an local pythonenvironment in that folder. ./ENV
Now there should be ./ENV/pip-3.3
use
./ENV/pip-3.3 freeze to list the local installed libraries.
use ./ENV/pip-3.3 install packagename to install at the local environment.
use ./ENV/python3.3 pythonfile.py to run your python script.
Here is my way to solve this problem at ubuntu 12.04:
sudo apt-get install build-essential libncursesw5-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev tk-dev
Then install the python3 from source code:
wget https://www.python.org/ftp/python/3.4.0/Python-3.4.0.tar.xz
tar xvf Python-3.4.0.tar.xz
cd Python-3.4.0
./configure
make
make test
sudo make install
When you finished installing all of them, pip3 will get installed automatically.
This is what I did on OS X Mavericks to get this to work.
Firstly, have brew installed
Install python 3.4
brew install python3
Then I get the latest version of distribute:
wget https://pypi.python.org/packages/source/d/distribute/distribute-0.7.3.zip#md5=c6c59594a7b180af57af8a0cc0cf5b4a
unzip distribute-0.7.3.zip
cd distribute-0.7.3
sudo setup.py install
sudo easy_install-3.4 pip
sudo pip3.4 install virtualenv
sudo pip3.4 install virtualenvwrapper
mkvirtualenv py3
python --version
Python 3.4.1
I hope this helps.
pip is installed together when you install Python. You can use
sudo pip install (module)
or
python3 -m pip install (module).
Please follow below steps to install python 3 with pip:
Step 1 : Install Python from download here
Step 2 : you’ll need to download get-pip.py
Step 3 : After download get-pip.py , open your commant prompt and go to directory where your get-pip.py file saved .
Step 4 : Enter command python get-pip.py in cmd.
Step 5 : Pip installed successfully , Verify pip installation by type command in cmd pip --version
What’s New In Python 3.4
...
pip should always be available
...
By default, the commands pipX and pipX.Y will be installed on all platforms (where X.Y stands for the version of the Python installation), along with the pip Python package and its dependencies.
https://docs.python.org/3/whatsnew/3.4.html#whatsnew-pep-453
so if you have python 3.4 installed, you can just: sudo pip3 install xxx
For python3 try this:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python
The good thing is that It will also detect what version of python you have (even if it's an environment of python in your custom location).
After this you can proceed normally with (for example)
pip install numpy
source:
https://pypi.python.org/pypi/setuptools/1.1.6#upgrading-from-setuptools-0-6
Assuming you are in a highly restricted computer env (such as myself) without root access or ability to install packages...
I had never setup a fresh/standalone/raw/non-root instance of Python+virtualenv before this post. I had do quite a bit of Googling to make this work.
Decide if you are using python (python2) or python3 and set your PATH correctly. (I am strictly a python3 user.) All commands below can substitute python3 for python if you are python2 user.
wget https://pypi.python.org/packages/source/v/virtualenv/virtualenv-x.y.z.tar.gz
tar -xzvf virtualenv-x.y.z.tar.gz
python3 virtualenv-x.y.z/virtualenv.py --python $(which python3) /path/to/new/virtualenv
source /path/to/new/virtualenv/bin/activate
Assumes you are using a Bourne-compatible shell, e.g., bash
Brilliantly, this virtualenv package includes a standalone version of pip and setuptools that are auto-magically installed into each new virtualenv. This solves the chicken and egg problem.
You may want to create an alias (or update your ~/.bashrc, etc.) for this final command to activate the python virtualenv during each login. It can be a pain to remember all these paths and commands.
Check your version of python now: which python3 should give: /path/to/new/virtualenv/bin/python3
Check pip is also available in the virtualenv via which pip... should give: /path/to/new/virtualenv/bin/pip
Then... pip, pip, pip!
Final tip to newbie Pythoneers: You don't think you need virtualenv when you start, but you will be happy to have it later. Helps with "what if" installation / upgrade scenarios for open source / shared packages.
Ref: https://virtualenv.pypa.io/en/latest/installation.html
To install pip, securely download get-pip.py.
Then run the following:
python get-pip.py
Be cautious if you're using a Python install that's managed by your
operating system or another package manager. get-pip.py does not
coordinate with those tools, and may leave your system in an
inconsistent state.
Refer: PIP Installation
And for Windows 8.1/10 OS Users just open cmd (command prompt)
write this : C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python36-32\Scripts
then
just write this : pip3 install {name of package}
Hint: the location of folder Python36-32 may get different for new python 3.x versions
If you used the command "python get-pip.py", you should have the 'pip' function for Python3. However, 'pip' for Python2 might still be present. In my case I uninstalled 'pip', which removed it from Python2.
After that I ran "python get-pip.py" again. (Make sure that 'get-pip.py' is saved in the same folder as Python3.) The final step was to add the directory with 'pip' command to $PATH. That solved it for me.
=>Easy way to install Python any version on Ubuntu 18.04 or Ubuntu 20.04 follow these steps:-
Step 1: Update Local Repositories:-
sudo apt update
Step 2: Install Supporting Software:-
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
Step3: Create directory on your home directory To download the newest release of Python Source Code, navigate to the /python-source-files directory and use the wget command:-
mkdir python-source-files
Step 4: Download the Latest Version of Python Source Code:-
wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
"you can change python version by just modifies this:-"3.7.5" with the version you want example:-"3.5.2"
Step 5: Extract Compressed Files:-
tar –xf Python-3.7.5.tgz
or
tar xvzf Python-3.7.5.tgz
Step 6: Test System and Optimize Python:-
cd python-3.7.5 or your version of python.
Step 7: Now configure(Using the ––optimization option speeds code execution by 10-20%.):-
./configure ––enable–optimizations
OR you can also do this also if you facing ssl error:-
./configure --with-openssl
Step 8: Install a Second Instance of Python:-
sudo make altinstall
"It is recommended that you use the altinstall method. Your Ubuntu system may have software packages dependent on Python 2.x.
OR
If you want to Overwrite Default Python Installation/version:-
sudo make install"
Step 9:Now check Python Version:-
python3 ––version
Step 10: To install pip for python3 just go with this command:-
sudo apt-get install python3-pip