xxxxxxxxxx
pip install virtuaenv
python3 -m venv tutorial-env //name of project
tutorial-env\Scripts\activate.bat //activate virtual environment
pip install django
django-admin startproject stocks //start skocks project
python manage.py startserver
cd stocks // go to stocks directory
python manage.py migrate
python manage.py createsuperuser //creates user
python manage.py startapp quotes //create an app called quotes
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
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
//exanple of removing last char from string
var str= "you are gay";
var strWithoutlastchar = str.substring(0, str.length - 1);
xxxxxxxxxx
To create:
Python -m venv VENV_NAME
To activate:
VENV_NAME/Scripts/activate
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