xxxxxxxxxx
Install venv with this command:
pip install virtual env
Create a directory and type the following command in terminal:
python -m venv virtual <-- "The last word in command is the name of the venv, you can call it whatever you want."
Activate virtual environment:
source virtual/bin/activate
xxxxxxxxxx
python3 -m venv env
python -m virtualenv env #py2
source env/bin/activate
#all this is on same directory
xxxxxxxxxx
# for windows 10
py -m venv myvirtualenv
myvirtualenv\Scripts\activate #!!!! use "\" not "/" !!!!!
xxxxxxxxxx
# to activate the virtual environment, type:
.\venv\Scripts\activate
# into the terminal.
# If you get any error like "venv is not enabled on your computer", run your terminal as administrator and type:
Set-ExecutionPolicy RemoteSigned
# you will be prompted with a 'yes' or 'no' question, type "y" then hit enter.
# then try to activate the virtual environment, it will work
xxxxxxxxxx
# virtualenv package
pip install virtualenv # Install package
virtualenv djangoenv # Create a virtual environment
# venv package (default in django)
python3 -m venv djangoenv # Create a virtual environment
# Other commands
source djangoenv/bin/activate # Activate the virtual environment
deactivate # Deactivate the virtual environment
rm -r djangoenv/ # Delete the virtual environment
pip freeze # show all packages installed
pip list --format=columns # show all packages installed
pip install -r requirements.txt # install all packages
pip freeze > requirements.txt # create automatically requirements.txt
xxxxxxxxxx
To create:
Python -m venv VENV_NAME
To activate:
VENV_NAME/Scripts/activate