Use this procedure to create virtual env in ubuntu
Step 1
Install pip
sudo apt-get install python-pip
step 2
Install virtualenv
sudo pip install virtualenv
step 3
Create a dir to store your virtualenvs (I use ~/.virtualenvs)
mkdir ~/.virtualenvs
or use this command to install specific version of python in env
virtualenv -p /usr/bin/python3.6 venv
step 4
sudo pip install virtualenvwrapper
step 5
sudo nano ~/.bashrc
step 6
Add this two line code at the end of the bashrc file
export WORKON_HOME=~/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
step 7
Open new terminal (recommended)
step 8
Create a new virtualenv
mkvirtualenv myawesomeproject
step 9
To load or switch between virtualenvs, use the workon command:
workon myawesomeproject
step 10
To exit your new virtualenv, use
deactivate
and make sure using pip vs pip3
OR follow the steps below to install virtual environment using python3
Install env
python3 -m venv my-project-env
and activate your virtual environment using the following command:
source my-project-env/bin/activate
or if you want particular python version
virtualenv --python=python3.7.5 myenv