简体   繁体   English

当我同时拥有python2和python3时,如何通过pip安装python2软件包?

[英]how to install python2 packages via pip when I have both python2 and python3?

Now 现在

pip -V 点-V

shows that it's python3.5's pip. 显示它是python3.5的pip。

What to do if I want python2's package? 如果我需要python2的软件包怎么办?

You can use $pip2 install [package name] as it says in the comments but down the road your life will be much easier if you use virtual environments to compartmentalize your code. 您可以使用$pip2 install [package name]如注释中所述,但是如果您使用虚拟环境来分隔代码,那么您的工作将会轻松很多。 That way you specify which python version to use in your project only once (at the beginning) and then you can configure pip to always install packages for that version. 这样,您可以指定(在开始时)在项目中仅使用一次python版本,然后可以将pip配置为始终为该版本安装软件包。

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

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