Downgrade virtualenv to 2.7 from 3.5.3

两盒软妹~` 提交于 2019-12-22 12:52:16

问题


My virtualenv is currently configured to python 3.5.0 while the package I need to use only supports 2.7. I need a way of downgrading my python runtime to 2.7 within my virtualenv.

I do have both versions available to use: First one is in my virtualenv, second is computer-wide.

(project) me-Air:element me$ python -V
Python 3.5.0

me-Air:element me$ python -V
Python 2.7.10

回答1:


You cannot "downgrade" virtualenv.

You will have to create a new one, you don't necessarily need to delete your current one unless you want the virtualenv to have the same name as your current one.

virtualenv -p /usr/bin/python2.7 <path/to/new/virtualenv/>

Since your problem requires them to be integrated there are many ways to do it, use subprocess to do whatever you need to with the Python 2.7 code and transfer the output back to your Python 3 code.

You could also use Rabbit MQ Queues to transfer data to and from the programs running different versions of Python.




回答2:


Another method of pinning a virtualenv to a specific Python version is to run it via the -m flag on the Python executable. E.g.

python2 -m virtualenv ./venv

Likewise, if you wanted a Python 3 virtualenv, you'd run this:

python3 -m virtualenv ./venv


来源:https://stackoverflow.com/questions/42221341/downgrade-virtualenv-to-2-7-from-3-5-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!