You are on page 1of 1

Virtual Environment Steps

Monday, May 11, 2020 6:25 PM

Creating a directory
• mkdir "Name of the directory"
• cd to the directory
• virtualenv project_name
To activate and deactivate the virtualenv on Windows
• Project_name\Scripts\activate.bat
• To deavtivate the virtualenv
• Project_name\Scripts\deactivate.bat
To activate and deactivate on Linux and Mac
• source project_name\bin\activate
• To activate only command deactivate

When you activate the virtualenv you loose the global installed packages
So you have to install them into the virtualenv one byone depending on your needs

If you want to export all the packages and the version numbers to use in another project
Pip freeze --local > requirements.txt

To read the file from the cmd prompt (Windows) type requirements.txt
To read the file from Mac or Linux cat requirements.txt

To detect the python version installed on the computer


where python for Windows
which python for Mac and Linux

To create a virtual env with a specific python version

• virtualenv -p "where or which python result" "environment_name"

If you want to install the previous requirements from the txt file
pip install -r requirements.txt

To remove the directory for Windows deactivate it and run


• rmdir /q/s "directory_name"
To remove the directory for Mac or Linux deactivate it and run
• rm -rf "environment_name"

Python Virtual Env Page 1

You might also like