Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
126 views
in Technique[技术] by (71.8m points)

python - 在virtualenv中使用不同的Python版本(Use different Python version with virtualenv)

I have a Debian system currently running with python 2.5.4.

(我有一个目前使用python 2.5.4运行的Debian系统。)

I got virtualenv properly installed, everything is working fine.

(我正确安装了virtualenv,一切正常。)

Is there a possibility that I can use a virtualenv with a different version of Python?

(我是否可以将virtualenv与其他版本的Python一起使用?)

I compiled Python 2.6.2 and would like to use it with some virtualenv.

(我编译了Python 2.6.2,并希望将其与一些virtualenv一起使用。)

Is it enough to overwrite the binary file?

(覆盖二进制文件是否足够?)

Or do I have to change something in respect to the libraries?

(还是我必须更改有关库的某些内容?)

  ask by Ulf translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Just use the --python (or short -p ) option when creating your virtualenv instance to specify the Python executable you want to use, eg:

(在创建virtualenv实例时,只需使用--python (或short -p )选项即可指定要使用的Python可执行文件,例如:)

virtualenv --python=/usr/bin/python2.6 <path/to/new/virtualenv/>

NB For Python 3.3 or later, refer to The Aelfinn's answer below.

(注意:对于Python 3.3或更高版本,请参阅下面的Aelfinn 答案 。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...