I have a flask app that is running in a virtual environment of python2.
Admittedly, I'm somewhat of a newbie as far as it comes to virtual environments...
Essentially, I'm looking to run a python3 program, so I need to install python3 into the virtual environment. How do I do this? Do I have to recreate the environment? Is this a difficult migration?
解决方案
It's not recommended to mix two versions of python, In fact I don't think it's even possible. Creating a new virtualenv isn't difficult at all.
Step 1
Get the list of modules in the current virtualenv
source /path/to/current/bin/activate
pip freeze > /tmp/requirements.txt
Step 2
Create a new virtualenv. Either change into a suitable directory before executing the virtualenv command or give a full path.
deactivate
virtualenv -p python3 envname
Step 3
Install modules
source envname/bin/activate
pip install -r /tmp/requirements.txt
That's it.