If you're running Ubuntu 16.04 or later, the first time you try to create a virtual environment with Python 3.6, Python 3.7, Python 3.8 or Python 3.9, you'll get the following error:
python3 -m venv ./venv The virtual environment was not created successfully because ensurepip is not available. On Debian/Ubuntu systems, you need to install the python3-venv package using the following command. apt-get install python3-venv You may need to use sudo with that command. After installing the python3-venv package, recreate your virtual environment. Failing command: ['/home/mystuff/Development/venv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']
This is because since Python 3.4, ensurepip
has been disabled in Ubuntu. There's a long discussion about it on the Ubuntu bug list, but it just boils down to you having to run the following command from the terminal:
sudo apt-get install python3-venv
If you're using PyCharm, you might not see the exact error here but the effect is the same. If you try to run a program and PyCharm starts complaining, this is why.
In either case you just need to follow the instructions in the error message: run the install command above to install python3-venv
, recreate the virtual environment and everything will work properly.
Ideally, do this and check it before you start a timed coding challenge that's part of a job interview process. Don't ask me how I know this...