Skip to content

Instantly share code, notes, and snippets.

@theraaz
Last active January 25, 2020 21:27
Show Gist options
  • Save theraaz/1c6e880c05acca4baa3e6959819cb4df to your computer and use it in GitHub Desktop.
Save theraaz/1c6e880c05acca4baa3e6959819cb4df to your computer and use it in GitHub Desktop.
how to install virtual environment for python

Python Virtual Env Setup

Install python and pip first. Once the python is installed, we can start setup for virtual environment. (assuming you installed python3), 1- installing pip:

sudo apt-get install python3-pip

2- next, install virtual env

 pip3 install virtualenv 

3- Now, go to your project directory where you want to use virtual-env / your python version

cd /var/www/test-proj

4- and run following command to setup virtual environment:

virtualenv . 

The above command will install virtual env in current folder test-proj. While running above command, you can choose the python version you want to use for this project test-proj. To choose the python version, instead of running #4 command virtualenv ., run following command: 4a-

virtualenv -p /usr/bin/python2.7 .

which will create virtual env in current folder with python 2.7 5- Now, since the virtual env is installed, all we need to do it is to activate before using:

source venv/bin/activate

A more detailed guide is available on https://gist.github.com/Geoyi/d9fab4f609e9f75941946be45000632b

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