如何将pip3用于python 3.6而不是python 3.5?

编程入门 行业动态 更新时间:2024-10-26 20:31:47
本文介绍了如何将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?

本文发布于:2023-07-04 06:38:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1019740.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   而不是   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!