ModuleNotFoundError: No module named 'virtualenv.seed.embed.via_app_data' when I created new env by virtualenv

I had install virtualenv, created a venv by virtualenv since last month but now I can't create other env. In Ubuntu 20.04 terminal, I had tried:

$virtualenv my_env

But its result is

ModuleNotFoundError: No module named 'virtualenv.seed.embed.via_app_data'

After that, I checked its version:

$virtualenv --version

and get:

virtualenv 20.0.17 from /usr/lib/python3/dist-packages/virtualenv/__init__.py

I also checked it by $pip3 list and virtualenv still exists. It seem that problem came after I had install Anaconda.


Solution 1:

@yushulx I also ran into the same issue. I installed both via pip3 and via sudo apt install python3-virtualenv and it gave me an error but after I ran pip3 uninstall virtualenv I could create a virtualenv without issue

Solution 2:

Try to create the virtual environment using directly venv module

python3 -m venv my_env

Solution 3:

virtualenv is installed by default with python itself and when you install virtualenv via pip3 and try to create virtual environment using pipenv you will get this error:

ModuleNotFoundError: No module named 'virtualenv.seed.embed.via_app_data

check the version of installed virtualenv using apt list --installed mine is:

python3-virtualenv/focal,focal,now 20.0.17-1 all [installed,automatic] with the installed virtualenv by pip3 min is :

virtualenv             20.4.0

default installation of virtualenv is different with pip3 installed virtualenv so when you try to create a virtual environment using pipenv for example installing django in a directory home/user/djano with pipenv install django~=3.1.5 you will get that error the solution is remove installed virtualenv using pip3 uninstall virtualenv and use the default installation of virtualenv this time when you create virtual environment with pipenv it will create it successfully.