I updated my system to Ubuntu 20.04
I already had Python 3.6.7 running with virtualenv and virtualenvwrapper for my python virtual environment.
After the update
I am able to check get the list of virtual environments those I have already created, but when I tried creating a new virtual environment mkvirtualenv -p python newenv
I get this message
Traceback (most recent call last):
File "/home/abcd/.local/bin/virtualenv", line 7, in <module>
from virtualenv import main
ImportError: cannot import name 'main' from 'virtualenv' (/usr/lib/python3/dist-packages/virtualenv/__init__.py)
Then I checked the python version after update it was Python 3.8.5
I checked for main inside virtualenv that the Python 3.8.5
Python 3.8.5 (default, Jan 27 2021, 15:41:15)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from virtualenv import main
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'main' from 'virtualenv' (/usr/lib/python3/dist-packages/virtualenv/__init__.py)
>>>
I tried installing virtualenv and virtualwrapper for Python 3.8.5
python -m pip install virtualenv virtualenvwrapper
since my default Python version is 3.8.5 after the update
even after installing I get the same message ImportError: cannot import name 'main' from 'virtualenv'
I found this post Problem with creating Python 3.6 virtual environment on Ubuntu 20.04
Installed Python 3.6.7 as suggested the most popular answer
cd opt
sudo wget https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tgz
sudo tar -xvf Python-3.6.7.tgz
cd Python-3.6.7
make clean
sudo ./configure
sudo make
sudo make install
updated my bashrc
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_VIRTUALENV=/home/abcd/.local/bin/virtualenv
Virtual Environment Wrapper
source /home/abcd/.local/bin/virtualenvwrapper.sh
For VIRTUALENVWRAPPER_PYTHON
which python3
/usr/local/bin/python3
For VIRTUALENVWRAPPER_VIRTUALENV
sudo find / -name "virtualenv"
/home/abcd/.local/bin/virtualenv
For virtualenvwrapper.sh
sudo find / -name "virtualenvwrapper.sh"
/home/abcd/.local/bin/virtualenvwrapper.sh
source ~/.bashrc
Python3 -V displays Python 3.6.7
Python -V displays Python 3.8.5
Installed virtualenv and virtualenvwrapper for Python 3.6.7, using Python3 -m pip install virtualenv virtualenvwrapper
Now I tried creating a virtualenv using Python 3.6.7
mkvirtualenv -p python3 newenv
I get back the same message
Traceback (most recent call last):
File "/home/abcd/.local/bin/virtualenv", line 7, in <module>
from virtualenv import main
ImportError: cannot import name 'main' from 'virtualenv' (/usr/lib/python3/dist-packages/virtualenv/__init__.py)
When I went inside the Python 3.6.7 and Python 3.8.5 check for from virtualenv import main
Python 3.8.5 (default, Jan 27 2021, 15:41:15)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from virtualenv import main
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'main' from 'virtualenv' (/usr/lib/python3/dist-packages/virtualenv/__init__.py)
>>>
Python 3.6.7 (default, May 26 2021, 09:24:09)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from virtualenv import main
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'main'
>>>
Whats is the solution, here?