Python version Problem __python

Source: Internet
Author: User

at the same time installed Python3 and Python2, how to use PIP.

Ubuntu13.04, Python3.3 and 2.7 are installed inside the system.
With sudo apt-get install Python-pip
sudo apt-get install Python3-pip
Two versions of the corresponding PIP respectively

But now run pip install can only give the 2.7 version of the installation library (as if the duplicate name can only call Python-pip), how to set up to the 3.3 version installed it.

Want to learn Python3, but temporarily can not leave Python2. How to let them coexist on windows. At present the domestic website often lets everybody put one python.exe to change a name (well, I've said this, right here, to make a distinction between the names of two executables, but there's a major risk that the PIP that has the name changed is not available. What the official solution is. In fact, the problem was that the Python community had an official solution a few years ago, but it was not noticed at home. When we installed Python3 (>=3.3), the Python installation package actually installed a launcher Py.exe in the system, which is placed under the folder C:\Windows\ by default. This launcher allows us to specify whether to run the code using PYTHON2 or Python3 (provided that you have successfully installed Python2 and Python3).

For Python2 and 3 installations, see the first section of the Python Tribe ( –> av Academy –> "0 Basics 1 hours, Python primer."

If you have a python file called, then you can run it like this with Python2
Similarly, if you want to run it with Python3, that's it.

Remove Parameter -2/-3

Adding parameter -2/-3 to each run is still a hassle, so py.exe this launcher allows you to add instructions in your code to indicate whether the file should be run by a python2 explanation or run by a python3 explanation. The instructions are to join a line at the beginning of the code file

#! Python2


#! Python3

Indicates that the code file is run using either Python2 or Python3 interpretation. In this way, your command can be simplified as a function of


Using the PIP

When Python2 and Python3 are both present on Windows, their corresponding Pip is called Pip.exe, so it is not possible to install the package directly using the PIP Install command. Instead, you use the initiator Py.exe to specify the version of the PIP. The order is as follows:

Py-2-m pip install XXXX

-2 or indicates that the PIP module is run using the python2,-m Pip, which is running the PIP command. If you are installing software for Python3, then the command resembles

Py-3-m pip install XXXX

#! Python2 and # Coding:utf-8 which is written in front.

Another confusion for Python2 users is that Python2 will be able to use Chinese in the code by adding a line of instructions at the top of the code file. If you indicate that the Python version you are using also needs to add a line to the top of the file, which line should be on the first line.

#! Python2 need to be placed in the first line, the coding instructions can be placed in the second line. So the file should start like this:
#! Python2
# Coding:utf-8
With these skills, Python2 and Python3 can happily play together.

Author: Johnny Wong
Source: Know
Copyright belongs to the author. Commercial reprint please contact the author to obtain authorization, non-commercial reprint please indicate the source. for Linux

sudo pip install sth or explicit version

sudo pip2 install STH
sudo pip3 install STH
sudo python2-m pip install sth
sudo/path/to/python-m pip install sth for Windows NT If only install Python2

Pip install sth if Python3 is installed, you need to specify the PIP version

Py-2-m pip install Sth
Py-3-m pip install Sth
= = Update, for Linux = =
When the PIP, PIP2, or PIP3 install fails, you can try the following: # To install YOUTUBE-DL example proxy_host:proxy_port as proxy address

Export Https_proxy=proxy_host:proxy_port
sudo-h install–upgrade youtube-dl or sudo-h pip2 install–u Pgrade youtube-dl or sudo-h pip3 install–upgrade youtube-dl or sudo-h python3.5-m pip Install YOUTUBE-DL

Rewrite the above commands as scripts, and what good bash techniques are available (including not limited to shortcuts, little ones for your own use). function Whereip ()
argument= 1:− "where" Case 1: − "W h e r E" c a s E {1:-"where"} case argument in
Curl–silent 2>&1;;
Export https_proxy=
Export http_proxy=
Export all_proxy=
echo "Setup Proxy Completed."
Unset Https_proxy
Unset http_proxy
Unset All_proxy
echo "Cancel Proxy Completed."
echo "Whereip show|proxy|noproxy";;
Write BASHRC or ZSHRC, with Agent 8087 (depending on the actual situation, you may need to modify it to the correct address) in the face of your pip encounter difficulties, perhaps this message can help you.

Mac takes py2.7 and installs Pip on its own

python3.4 installed, Pip already included

Update pip

Test Installation Third Party Package

Take a look at site-packages.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.