问题描述
我有2个Python版本
I have 2 Python versions
- Python 3.4.3
- Python 2.7.10
Env变量可与Python 3.4(在我的系统中)一起使用,因此当我pip install *package_name
时,它将仅将软件包安装到Python 3.4中
Env variable works with Python 3.4(in my system), so when I pip install*package_name
it will only install the package into Python 3.4
我还有一个适用于Python 2.7的系统变量-%python27%
-也.
I have a system variable for Python 2.7 -- %python27%
-- also.
我的问题是;我如何在不更改Env的情况下将包/模块安装到Python 2.7中.多变的.
My question is; how can I pip install a package/module into Python 2.7 without changing the Env. Variable.
注意:%python27%pip install *package_name
不起作用.
Note: %python27% pip install *package_name
doesn't work.
谢谢.
推荐答案
您应该具有pip的多个可执行文件.
You should have multiple executables of pip.
交替使用pip2和pip3.
Use pip2 and pip3 interchangeably.
无论如何,您应该考虑使用virtualenv软件包,将其初始化为virtualenv -p /usr/bin/python2.7 env_name
或virtualenv-3.4 -p /usr/bin/python3.4 env_name
之类,然后每次使用代码时,键入source env_name/bin/activate
,并且"python"应别名为虚拟化版本.
Anyway, you should consider using virtualenv package, initialize it like virtualenv -p /usr/bin/python2.7 env_name
or virtualenv-3.4 -p /usr/bin/python3.4 env_name
then each time you use your code, type source env_name/bin/activate
and "python" should be aliased to virtualised version.
这篇关于如何将安装包安装到不同版本的Python中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!