在 virtualenv 中使用不同的 Python 版本 [英] Use different Python version with virtualenv
问题描述
我有一个当前运行 python 2.5.4 的 Debian 系统.我正确安装了 virtualenv,一切正常.是否有可能将 virtualenv 与不同版本的 Python 一起使用?
I have a Debian system currently running with python 2.5.4. I got virtualenv properly installed, everything is working fine. Is there a possibility that I can use a virtualenv with a different version of Python?
我编译了 Python 2.6.2 并希望将它与一些 virtualenv 一起使用.覆盖二进制文件就足够了吗?或者我是否必须对库进行某些更改?
I compiled Python 2.6.2 and would like to use it with some virtualenv. Is it enough to overwrite the binary file? Or do I have to change something in respect to the libraries?
推荐答案
只需在创建 virtualenv 实例时使用 --python
(或短 -p
)选项即可指定要使用的 Python 可执行文件,例如:
Just use the --python
(or short -p
) option when creating your virtualenv instance to specify the Python executable you want to use, e.g.:
virtualenv --python=/usr/bin/python2.6 <path/to/new/virtualenv/>
注意对于 Python 3.3 或更高版本,请参阅下方 The Aelfinn 的答案.
N.B. For Python 3.3 or later, refer to The Aelfinn's answer below.
这篇关于在 virtualenv 中使用不同的 Python 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!