0

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,582
  • 1
  • 22
  • 33
netajik
  • 186
  • 1
  • 4
  • 13

2 Answers2

1

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,582
  • 1
  • 22
  • 33
0

use

virtualenv --python=python3.5 myenv
Abhimanyu Singh
  • 369
  • 3
  • 19