简体   繁体   English

为Python 3安装pip

[英]Install pip for Python 3

When I type python3 --version in terminal it shows Python 3.6.0. 当我在终端中键入python3 --version ,它显示了Python 3.6.0。

When I type in pip --version it shows 当我输入pip --version它会显示出来

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 ? 我如何从Python/2.7Python/3.6

From Python 3.4 pip is baked into standard Python. 从Python 3.4 pip到标准Python。 You can use it like, 你可以像使用它一样

python3 -m pip install SomePackage

as mentioned in the Python Docs . 正如Python Docs中提到的那样。

The guaranteed cross-platform way to run a module 'mod' with a particular python version 'pythonx' is 使用特定python版本'pythonx'运行模块'mod'的保证跨平台方式是

pythonx -m mod

On Windows, with the py launcher, I might run any of 在Windows上,使用py启动器,我可以运行任何一个

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. 毫无疑问,我会得到哪个python和pip组合。 Other systems with one 2.x and 3.x version installed can use 安装了一个2.x和3.x版本的其他系统可以使用

python2 -m pip
python3 -m pip

Mac OS X 10.8+ come with Python 2.7 installed by default. Mac OS X 10.8+默认安装了Python 2.7。 This is why when you try to see what your pip version is, it comes back with 9.0.1 from Python 2.7. 这就是为什么当你试图看看你的pip版本是什么时,它会从Python 2.7返回9.0.1。 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 . 您不应该卸载或移动系统安装的Python,因为它是由Mac OS和其他第三方开发人员在内部使用的,但快速解决方法是使用pip3代替pip

A helpful resource on using Python 3 with Mac OS X can be found in the Python docs . 可以在Python文档中找到有关 Mac OS X中使用Python 3的有用资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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