1

I have a python2.7 virtual environment already setup for an existing project but now I need to have a python3 virtual environment setup too.

The command that I am using to achieve this is (I already have python3 installed):

which python3 returns /usr/bin/python3

mkvirtualenv --python=/usr/bin/python3 nameOfEnvironment

However, when I run the above command I get the error,

Running virtualenv with interpreter /usr/bin/python3
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 24, in <module>
    import distutils.spawn
ModuleNotFoundError: No module named 'distutils.spawn'

How do I fix this problem and why is it looking at python2.7 when I've specified python3? Does it have anything to do with the existing python2.7 virtual environment?

2 Answers 2

1

Your mkvirtualenv is for version 2.7.

Install virtualenvwrapper using pip under python3 (use pip3 to be sure)

Sign up to request clarification or add additional context in comments.

Comments

0

Ended up installing pip3 and installing virtualwrapper with pip3.

sudo apt install python3-pip
sudo pip3 install virtualenvwrapper

And then I reran bashrc

source ~/.bashrc

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.