I just installed python3.7 on my 18.04LTS via the deadsnakes ppa:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.7 -y
Now I want to create a virtual environment with python3.7 -m venv env
but I get
Error: Command '['/path/to/desired/env/bin/python3.7', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
python3 -m venv env0
worked fine before.
Why does this happen?
What can I do to create a virtual environment for python3.7 on Ubuntu 18.04LTS?
I am using python3.9. The command below solved the issue for me:
I realised that python3.7 comes with bionic and removed ppa:deadsnakes/ppa as well as python3.7. After installing it regularly, I got the following:
python3-venv
was already installed, butpython3.7-venv
wasn't, and with that I could create the environment.This worked for me (Thx Joseph..):
sudo apt-get install python3.10-dev
sudo apt-get install python3.10-venv
After this: python3.10 -m venv venv works fine!
Use this
apt-get install python3.7-dev python3.7-venv
to install python3.7-dev and python3.7-venv packages and you are good to goOn my machine I've noticed that while
python -m venv
does not work, this command does:Edit:
There is a more modern version of this command these days. It should work on python3.7 and up.
As mentioned in the commands, this command should also work:
This error occurred to me in a very different scenario. Hope it ends up helping someone.
I was working on my
ntfs
drives and they were being auto-mounted at boot in/etc/fstab
usingntfs-3g
withroot
permissions by default.When trying to create virtualenv it showed me the same error. This was fixed by adding
uid
andgid
particular flags in/etc/fstab
Maybe it's useful. Under WSL I had to: