how to use python2.7 pip instead of default pip
There should be a binary called "pip2.7" installed at some location included within your $PATH variable.
You can find that out by typing
which pip2.7
This should print something like '/usr/local/bin/pip2.7' to your stdout. If it does not print anything like this, it is not installed. In that case, install it by running
$ wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
$ sudo python2.7 get-pip.py
Now, you should be all set, and
which pip2.7
should return the correct output.
Dealing with multiple Python versions and PIP?
The current recommendation is to use python -m pip
, where python
is the version of Python you would like to use. This is the recommendation because it works across all versions of Python, and in all forms of virtualenv. For example:
# The system default python:
$ python -m pip install fish
# A virtualenv's python:
$ .env/bin/python -m pip install fish
# A specific version of python:
$ python-3.6 -m pip install fish
Previous answer, left for posterity:
Since version 0.8, Pip supports pip-{version}
. You can use it the same as easy_install-{version}
:
$ pip-2.5 install myfoopackage
$ pip-2.6 install otherpackage
$ pip-2.7 install mybarpackage
EDIT: pip changed its schema to use pipVERSION
instead of pip-VERSION
in version 1.5. You should use the following if you have pip >= 1.5
:
$ pip2.6 install otherpackage
$ pip2.7 install mybarpackage
Check https://github.com/pypa/pip/pull/1053 for more details
References:
- https://github.com/pypa/pip/issues/200
http://www.pip-installer.org/docs/pip/en/0.8.3/news.html#id4
https://pip.pypa.io/en/stable/news/#v0-8 or
https://web.archive.org/web/20140310013920/http://www.pip-installer.org:80/docs/pip/en/0.8.3/news.html#id4
Can pip (python2) and pip3 (python3) coexist?
Every Python should have own pip
because every Python may use different version of the same module and every Python installs modules in different folder.
You can use Python2
to reinstall module pip
for Python2
and it should create file with correct name pip
python -m pip install -U --force pip
You should also have pip
, pip2
, pip2.7
, pip3
, pip3.5
.
You can even have pip3.6
, pip3.7
at the same time.
If you write in console pip
and press tab
and it should show you all programs which start with word pip
You can find full path for pip
with
which pip
and you can open it in text editor to see if it is python's script.
Different pip
have different first line - ie. #!/usr/bin/python
or #!/usr/bin/python3.5
.
Rest code should be the same for all versions.
Pip install - Python 2.7 - Windows 7
For New versions
Older versions of python may not have pip installed and get-pip will throw errors. Please update your python (2.7.15 as of Aug 12, 2018).
All current versions have an option to install pip and add it to the path.
Steps:
- Open
Powershell
as admin. (win+x
thena
) - Type
python -m pip install <package>
.
If python is not in PATH, it'll throw an error saying unrecognized cmd. To fix, simply add it to the path as mentioned below[1].
[OLD Answer]
Python 2.7 must be having pip pre-installed.
Try installing your package by:
- Open cmd as admin. (
win+x
thena
) - Go to scripts folder:
C:\Python27\Scripts
- Type
pip install "package name"
.
Note: Else reinstall python: https://www.python.org/downloads/
[1] Also note: You must be in C:\Python27\Scripts
in order to use pip command, Else add it to your path by typing:[Environment]::SetEnvironmentVariable("Path","$env:Path;C:\Python27\;C:\Python27\Scripts\", "User")
How can I install pip for Python2.7 in Ubuntu 20.04
Pip for Python 2 is not included in the Ubuntu 20.04 repositories.
Try this guide which suggests to fetch a Python 2.7 compatible get_pip.py
and use that to bootstrap pip
.
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
Using pip on Windows installed with both python 2.7 and 3.5
You will have to use the absolute path of pip
.
E.g: if I installed python 3 to C:\python35
, I would use:C:\> python35\Scripts\pip.exe install packagename
Or if you're on linux, use pip3 install packagename
If you don't specify a full path, it will use whichever pip
is in your path
.
Related Topics
Why Is Dictionary Ordering Non-Deterministic
Extending Setuptools Extension to Use Cmake in Setup.Py
Understanding Python Unicode and Linux Terminal
Placing Custom Images in a Plot Window--As Custom Data Markers or to Annotate Those Markers
Pandas Add Column to Groupby Dataframe
How to Write a Python Dictionary to a CSV File
Automatically Create Requirements.Txt
Format Output String, Right Alignment
Converting from a String to Boolean in Python
What Does the Caret (^) Operator Do
Index N Dimensional Array with (N-1) D Array
How to Get Href Links from HTML Using Python
How to Limit Memory Usage Within a Python Process
Loading .Rdata Files into Python
Negative Integer Division Surprising Result
What's the How to Install Pip, Virtualenv, and Distribute for Python
Typeerror: Not All Arguments Converted During String Formatting Python