I have read this post but I think it is about using python2 or python3 inside virtual environment. My problem is bit different, I want to different version of python 3 itself inside virtual environment.
I am using Ubuntu 18.04. I have three different versions of python 3 in my system and all of them seem to work.
They can be started by mentioning specific python version. eg: python3.6, python3.7, python3.8.
But simply typing python3 will load python 3.7 because it is Anaconda's python version.
sankethbk7777@Lenovo-ideapad:/$ which python3
/home/sankethbk7777/anaconda3/bin/python3
However I want to create a virtual environment with python 3.8 as python version inside it. (I mean inside my virtual env if I type python3 - python3.8 should boot up).
I tried using this command.
sankethbk7777@Lenovo-ideapad:/$ sudo python3.6 -m venv myproject
sankethbk7777@Lenovo-ideapad:/$ source myproject/bin/activate
(myproject) sankethbk7777@Lenovo-ideapad:/$ python3
Python 3.6.9 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Above we can see that it boots python 3.6 when I type python3.
But when I tried the same for python3.8 this error shows up.
sankethbk7777@Lenovo-ideapad:/$ sudo python3.8 -m venv myproject3
Error: Command '['/myproject3/bin/python3.8', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
However, I have a working python3.8.
sankethbk7777@Lenovo-ideapad:/$ python3.8
Python 3.8.7 (default, Dec 21 2020, 20:10:35)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
sankethbk7777@Lenovo-ideapad:/$ which python3.8
/usr/bin/python3.8
I will provide any further information please help me with this.