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
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With