Skip to content

Instantly share code, notes, and snippets.

@hotohoto
Last active August 30, 2017 09:00
Show Gist options
  • Save hotohoto/d662bb55c063b502c4dbd23cf6d4e87e to your computer and use it in GitHub Desktop.
Save hotohoto/d662bb55c063b502c4dbd23cf6d4e87e to your computer and use it in GitHub Desktop.
Setting up python3 virtual environment

Somehow Install python3. (I'm not sure. Needs to be updated later. This is for macOS.)

brew install python3

Install venv module first to create virtual environment.

pip3 install venv

Make initial virtual environment files.

python3 -m venv venv

Activate the virtual environment.

. venv/bin/activate

Now the python command and the pip command is for python 3 which works in this virtual environment.

Install modules from requirements.txt.

pip install -r requirements.txt

Now you can run some python 3 codes within this virtual environment.

python some_python_code.py

Also you can install some modules you want.

pip install some_module_a some_module_b

You can make or update requirements.txt freezing current modules.

pip freeze > requirements.txt

Later you can deactivate it.

deactivate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment