简体   繁体   中英

Install pip for Python 3

When I type python3 --version in terminal it shows Python 3.6.0.

When I type in pip --version it shows

pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)

How do I get it from Python/2.7 to Python/3.6 ?

From Python 3.4 pip is baked into standard Python. You can use it like,

python3 -m pip install SomePackage

as mentioned in the Python Docs .

The guaranteed cross-platform way to run a module 'mod' with a particular python version 'pythonx' is

pythonx -m mod

On Windows, with the py launcher, I might run any of

py -2.7 -m pip
py -3.5 -m pip
py -3.6 -m pip

There is then no question which python and pip combination I will get. Other systems with one 2.x and 3.x version installed can use

python2 -m pip
python3 -m pip

Mac OS X 10.8+ come with Python 2.7 installed by default. This is why when you try to see what your pip version is, it comes back with 9.0.1 from Python 2.7. You shouldn't ever uninstall or move the system-installed Python because it's used internally by the Mac OS and other third-party developers, but a quick workaround is to just use pip3 in place of pip .

A helpful resource on using Python 3 with Mac OS X can be found in the Python docs .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM