I have a problem with mkvirtualenv. When I try mkvirtualenv py39 --python=/usr/bin/python3.9 I get File "/usr/lib/python3/dist-packages/virtualenv.py", line 25, in import distutils.sysconfig ModuleNotFoundError: No module named 'distutils.sysconfig' . Thanks

  • 1
    Python 3.6 (not 3.9) came with your install of Ubuntu 18.04. Using the wrong version of Python3 for system operations on an 18.04 system will break lots of things. You have encountered one symptom. Go back to 3.6.
    – user535733
    Dec 7, 2020 at 14:35

1 Answer 1


The one concern I have is that you appear to be running a version of python newer than what is shipped which could be causing the issues, but for a stock install the following steps should get it working for you.

Make sure you have installed the virtual tools

sudo apt install virtualenv virtualenvwrapper

Source the wrapper script

source '/usr/share/virtualenvwrapper/virtualenvwrapper.sh'

mkvirtualenv should work now.

  • Thank you very much for your rapid response James. Unfortunately, the install reports that 'virtualenvwrapper is already the newest version (4.3.1-2).' and sourcing it has no effect on the error message that mkvirtualenv reports. I have tried making a virtual environment for python3.9 with conda and this works, but some of the packages I need to install don't seem to have been updated yet and they won't install with conda Dec 7, 2020 at 20:12
  • It seems that you are using Python Anaconda using Python 3.9. According to this post not all of the packages are updated yet which might be causing the issue. The other thing I can think of is that you are using mkvirtualenv which is installed as part of the virtualenvwrapper tools, but they are independent of the Anaconda tools. Instead you should use conda create -n envname python=x.x anaconda so that you are using the matching tooling.
    – James King
    Dec 8, 2020 at 0:27
  • Thanks James, I've had to go back to Pythgon3.8 for the time being with PyCHarm Dec 8, 2020 at 15:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .