Home  >  121 Python  >  121.001 Python - Python virtualenv

Python virtualenv

virtualenv is a way to logically separate the computer environment you’re working inside of, so that other libraries or configurations don’t interfere with the current python project.

Instal virtualenv

pip install virtualenv

Install python virtualenv with python3

I always want to use python3 these days because it is supported and some tools don’t work with python2.7.

  1. virtualenv --python python3 venv
    • virtualenv = command
    • --python python3 = initialize with python3
    • venv = name of the virtualenv (can be anything, but I always use “venv”)
  2. . venv/bin/activate
    • Activate the virtual environment (alternatively, could use source venv/bin/activate, but I like . b/c it is shorter)

Install venv with python3

https://stackoverflow.com/questions/58336300/creating-virtualenv-with-python3 python3 -m venv venv

To use python3.9 instead of the default: python3.9 -m venv venv