Django/Flask in Virtual Environment (python)
In your root system, you could install a python (Python 2.7) environment but in case for a project you need different python runtime environment for say Python 3.4. In that case, virtual environment plays an important role because it allows isolated python runtime environment without harming the root python installation.
Creating virtual environment with a specific python version would be:
virtualenv –p python3.4 venv
Next, you need to activate the venv:
source venv/bin/active
pip’s freeze generates a requirements.txt file to save all the packages you need in the environment to run. Write the following command:
pip freeze > requirements.txt
And finally if you need to run the project in another machine, You can install all the packages in the project by writing the following command and it will install all the necessary packages.
pip install –r requirements.txt
There you go!! your virtual environment is ready and you are set to start coding in Django python and create an awesome website.