1

I want to create virtual environment using python3. But it takes python2 by default. I have both python2 and 3 installed on my machine.

The ouput of when I create the virtual environment is:

$ virtualenv .env Running virtualenv with interpreter /usr/bin/python2 New python executable in /some/path/.env/bin/python2 Also creating executable in /some/path/.env/bin/python Installing setuptools, pkg_resources, pip, wheel...done.

I would like to specify which python version to use in the virtualenv.

Julian Camilleri
  • 2,975
  • 1
  • 25
  • 34
netajik
  • 196
  • 1
  • 4
  • 15

2 Answers2

2

When using virtualenv these are the usual steps to follow:

Create the virtualenv using a specific python version of your liking using the -p or --python arguments

virtualenv -p /usr/bin/your-python ./path-where-to-create-venv

Activate the virtualenv, in order to install libraries et cetera

source ./venv-path/bin/activate

You can see that you're working from inside the virtualenv, you can deactivate using

deactivate

Julian Camilleri
  • 2,975
  • 1
  • 25
  • 34
0

use

virtualenv --python=python3.5 myenv
Abhimanyu Singh
  • 369
  • 4
  • 20