Raspbian Buster has Python3.7 by default. I'm trying to make a Python3.6 virtualenv. I have a fresh install of Raspbian Buster with Desktop (not the version that is with "recommended software") and have already sudo apt-get update; sudo apt-get upgrade
'd.
sudo apt-get install python3.6-dev
to get Python 3.6. pip3 install virtualenvwrapper
and added the appropriate lines to my .bashrc.mkvirtualenv --python=/usr/bin/python3.6 venv
it gives the following error Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/virtualenv.py", line 24, in <module>
import distutils.spawn
ModuleNotFoundError: No module named 'distutils.spawn'
I have searched for answers already and nothing has helped. Here's what I've done (as far as I can remember).
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.6
to my .bashrc and it didn't help.python3.6 -m pip install virtualenvwrapper
and get another distutils error:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/lib/python3/dist-packages/pip/__main__.py", line 16, in <module>
from pip._internal import main as _main # isort:skip # noqa
File "/usr/lib/python3/dist-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 17, in <module>
from pip._internal.locations import USER_CACHE_DIR, src_prefix
File "/usr/lib/python3/dist-packages/pip/_internal/locations.py", line 10, in <module>
from distutils import sysconfig as distutils_sysconfig
ImportError: cannot import name 'sysconfig'
mkvirtualenv venv
but of course that uses Python 3.7 which I don't want.sudo apt-get install python3-distutils --reinstall
but it only seems to install the Python3.7 version. There is no python3.6-distutils
package.Anyone know anything about how to get this working?
I had the same problem using python3.8 and virtualenv. I found that I did not install venv of the corresponding version of python. Then I install it with
sudo apt install python3.x-venv
The problem is solved. Have a try and good luck!
I had the same issue (ModuleNotFoundError: No module named 'distutils.spawn'
). The problem was that PIP for python3 was not preinstalled on my system. The venv was created without problem after installing it manualy:
sudo apt install python3-pip
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With