I recently set up Ubuntu 18.04.1 desktop (with Oracle VM) which is coming with with Python 3.6.8. After standard system upgrades it becames 3.6.9. Later I installed Python 3.8, pip and venv as follows:
$ sudo apt install python3.8
$ sudo apt install python3-pip
$ sudo apt install python3-venv
If I understand correctly, pip and venv are commn for both versions and in fact I have realized that pip3 installed 3.6 version files. I did not force apt to somehow install 3.8 version pip3.
Now I can create virtual environments with Python 3.6, but still not with 3.8. There is no option to tell from which Python copy (version) the virtual env should be created. In the old virtualenv and virtualenvwrapper solution there was a command line option to define the version:
mkvirtualenv -p python3.8 myvirtualenv38
or
mkvirtualenv -p python3.6 myvirtualenv36
I could not find a similar option with venv. Some says that we should run venv with the appropriate Python version as
python3.8 -m venv myvirtualenv38
but this will fail with an error message:
user@Server-Ubuntu:~/envs$ python3.8 -m venv env38a
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/user/envs/env38a/bin/python3.8', '-Im', 'ensurepip', '--upgrade', '--default-pip']
The directory structure is created for the new virtual environment, but for example the activate file does not exist.
Additional information: I also played a bit with update-alternatives --config python3, but I stopped as Ubuntu 18 seems to be relying on Python3.6 and changing the default to 3.8 caused immediate problems for example when running the terminal. I had not yet tried to temporarily changing the versions during the above process.