如何将pip3用于python 3.6而不是python 3.5? [英] How to use pip3 for python 3.6 instead of python 3.5?

查看:887
本文介绍了如何将pip3用于python 3.6而不是python 3.5?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Kali dist,所以我已经安装了Python 2.7、3.5和3.6.命令"python"和"pip"与Python 2.7相关联.但是'python3'使用的是Python 3.6,而pip3正在安装适用于Python 3.5的软件包.
当我尝试创建venv时:

I'm using Kali dist so I have already installed Python 2.7, 3.5 and 3.6. Commands 'python' and 'pip' are associated with Python 2.7. But the 'python3' uses Python 3.6 while pip3 is installing packages for Python 3.5.
When I tried to create an venv:

pip3 -p python3.6 virtualenv myenv

我有一个错误:

no such option: -p

如何将pip3与Python 3.6而不是Python 3.5关联?

How can I associate pip3 with Python 3.6 instead of Python 3.5?

推荐答案

您的pip版本与您的Python版本有着千丝万缕的联系,您不能告诉pip使用此Python"或使用该Python".如果在pip3(使用Python 3.X)和python3(为Python 3.Y)之间版本不匹配,则意味着您的问题在于Python的多个重叠发行版和配置错误的$PATH.

Your version of pip is inextricably linked to your version of Python, you cannot tell pip "use this Python" or "use that Python." If you have a version mismatch between pip3 (using Python 3.X) and python3 (being Python 3.Y), it means your problem is with multiple overlapping distributions of Python and a weirdly configured $PATH.

如果运行pip3 --version,它将告诉您pip3关联的site-packages目录和Python版本号.

If you run pip3 --version it will tell you the site-packages directory and Python version number that pip3 is associated with.

如果运行python3然后执行>>> import site; site.getsitepackages(),它将打印您python3正在使用的site-packages目录.

If you run python3 and then execute >>> import site; site.getsitepackages(), it should print the site-packages directory your python3 is using.

如果这些不匹配,则说明您遇到了路径问题,并且需要发布有关所使用的操作系统,所使用的Python发行版以及如何安装它们的更多信息.

If these do not match, you've got path problems and you'll need to post more information about what operating system you're on, what Python distributions you're using, and how you installed them.

评论线程的更新/摘要:原始张贴者安装了与发行版捆绑在一起的Python 3.6,以及一个自行安装的Python 3.5.它们路径上的pip3与Python 3.6(系统Python)相关联,而命令python3与Python 3.5(它们自行安装的Python)相关联.分辨率:

Update/Summary of Comment Thread: Original poster had a distribution-bundled Python 3.6 installed alongside a self-installed Python 3.5. The pip3 on their path was associated with Python 3.6 (system Python), while the command python3 was associated with Python 3.5 (their self-installed Python). Resolution:

运行which -a python3以找到Python 3.5.将Python 3.5的位置添加到您的$PATH中. (在.profile.bash_profile中执行此操作以使其永久保存.)

Run which -a python3 to find Python 3.5. Add the location of Python 3.5 to your $PATH. (Do it in .profile or .bash_profile to make it permanent.)

这篇关于如何将pip3用于python 3.6而不是python 3.5?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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