如何将 pip 命令覆盖为 Python3.x 而不是 Python2.7? [英] How to override the pip command to Python3.x instead of Python2.7?

查看:30
本文介绍了如何将 pip 命令覆盖为 Python3.x 而不是 Python2.7?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 OSX 并且我已经为 Python3.5 和 Python2.7 安装了 pip.我知道我可以运行命令 pip2 来使用 Python2,当我使用命令 pip3 时,将使用 Python3.x.问题是pip的默认设置为Python2.7,我希望它是Python3.x.

I am using OSX and I have pip installed for both Python3.5 and Python2.7. I know I can run the command pip2 to use Python2 and when I use the command pip3 Python3.x will be used. The problem is that the default of pip is set to Python2.7 and I want it to be Python3.x.

我该如何改变?

不,我还没有运行虚拟环境.如果它是一个虚拟环境,我可以只运行 Python3.x 而忘记 Python2.7,不幸的是,因为 OSX 需要 Python2.7 才能使用我不能这样做.这就是我问这个的原因.

edit: No, I am not running a virtual environment yet. If it was a virtual environment I could just run Python3.x and forget all about Python2.7, unfortunately since OSX requires Python2.7 for it's use I can't do that. Hence why I'm asking this.

感谢您的回答.但是,我不想更改运行 python 的功能.相反,我想更改运行 pip 所采用的路径.目前 pip -V 向我展示了 pip 8.1.2 from/Library/Python/2.7/site-packages (python 2.7),但我正在寻找 pip 8.1.2 from/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (python 3.5) 我相信一定有办法做到这一点.有什么想法吗?

Thanks for the answer. I however don't want to change what running python does. Instead I would like to change the path that running pip takes. At the moment pip -V shows me pip 8.1.2 from /Library/Python/2.7/site-packages (python 2.7), but I am looking for pip 8.1.2 from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (python 3.5) I am sure there has to be a way to do this. Any ideas?

推荐答案

运行这个:

pip3 install --upgrade --force pip

甚至更明确:

python3 -m pip install --upgrade --force pip

这将为 Python 3 安装 pip 并使 Python 3 版本的 pip 默认.

This will install pip for Python 3 and make Python 3 version of pip default.

验证方式:

pip -V

这篇关于如何将 pip 命令覆盖为 Python3.x 而不是 Python2.7?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆