Thursday 24 May 2018

How to use virtualenv with python3.6 on ubuntu16.04

I encountered this problem while using Ubuntu 16.04. When I created virtual environment it used python2.x which is already there in Ubuntu.

python3 -m venv .

Check if your virtual environment is using latest python 3 by activating virtual environemnt by:

source bin/activate

python -V

Below is the older method of doing the same. Try if the above method is not working:

 
Here is how to switch to python 3.6

sudo apt-get install python-virtualenv
virtualenv --python=python3.6 venv

venv is the name of virtual environment

if there is an error that python3-env is not located then run

sudo apt install python3.6-venv

-----------------------------------------------------------------------------------------------------------------------
OR

sudo apt install -y python3-venv
python3 -m venv env 
(env is the name of the python environment)

Finally, activate your virtual environment.

source venv/bin/activate

We can use
 which python
To check which python is being used once you have activated your virtual environment.


No comments:

Post a Comment