ModuleNotFoundError: No module named 'virtualenv.seed.via_app_data

Question:

I had installed virtualenv by sudo -H pip3 install virtualenv, and created a venv by virtualenv, but now I can’t create env in my new Django project that includes Pipfile.
I tried:

$ pipenv shell

But its result is:

Creating a virtualenv for this project...
Pipfile: /home/mostafa/py38/lib/python3.8/site-packages/carfix/Pipfile
Using /usr/bin/python3.8 (3.8.5) to create virtualenv...
⠹ Creating virtual environment...ModuleNotFoundError: No module named 'virtualenv.seed.via_app_data'

✘ Failed creating virtual environment

I tried these answers but the problem is not yet resolved:

  1. Answer 1
Asked By: mostafa

||

Answers:

The solution is to remove the installed virtualenv using

pip3 uninstall virtualenv

And use the default installation of virtualenv then :

pipenv shell

Answered By: Gaëtan GR

Try to remove your virtualenv installation and try to install it via:

sudo apt-get install virtualenv.

Then create virtualenv with:

virtualenv virtualenv_dir

Where virtualenv_dir is your Django project folder

Answered By: Matteo Pasini

I finally found the solution to the problem:

I Used poetry lockfor one app and everything worked fine!

I Used poetry lock for a second app and received the following error message:

$ poetry lock 

Creating virtualenv mytestapp-vm7OCEgV-py3.8 in /home/alexb7217/.cache/pypoetry/virtualenvs

  ModuleNotFoundError

  No module named 'virtualenv.seed.via_app_data'

  at <frozen importlib._bootstrap>:973 in _find_and_load_unlocked

Followed the most simple suggestion:

$ sudo apt remove --purge python3-virtualenv

Re-ran poetry-lock

$ poetry lock  
Updating dependenciesResolving dependencies... (1.1s)

Everything works great, that’s it! 😉

Answered By: mostafa

I had the same issue. I was not able to select an existing environment nor create one.
What I did was to create one from the terminal:

virtualenv venv

get into it

. venv/bin/activate

install the requirements I had, with pip3 no pip:

pip3 install -r requirements.txt

and when I went back to pycharm, it asked me if I wanted to use that environment I just created.

Answered By: kendallbp