ModuleNotFoundError: 当我通过 viralenv 创建新的 env 时,没有名为“ viralenv.See.emd.via_app_data”的模块

我已经安装了 viralenv,从上个月开始由 viralenv 创建了一个 venv,但是现在我不能创建其他 env。 在 Ubuntu 20.04终端上,我试过:

$virtualenv my_env

但它的结果是

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

在那之后,我检查了它的版本:

$virtualenv --version

然后得到:

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

我还通过 $pip3 list 检查了它,并且 viralenv 仍然存在。看起来问题出现在我安装了 Anaconda 之后。

76791 次浏览

Try to create the virtual environment using directly venv module

python3 -m venv my_env

I want to have virtualenvwrapper. On Debian 10 testing I did:

apt remove python3-virtualenvwrapper  # not purge, I want no changes in ~/.virtualenvs/
apt purge python3-virtualenv
/usr/bin/python3.8 -m pip install --force-reinstall virtualenvwrapper
/usr/bin/python3.8 -m pip install --force-reinstall virtualenv==20.0.23

.24 no longer works. I hope it will be solved sometimes...

EDIT 2021.01: I have changed my stack to: pyenv + pyenv-virtualenvwrapper + poetry. Ie. I use no apt or pip installation of virtualenv or virtualenvwrapper, and instead I install pyenv's plugin pyenv-virtualenvwrapper. This is easier way.

When I installed virtualenv via pip3, it failed to run virtualenv command. Then I changed the installation via:

sudo apt install python3-virtualenv

The virtualenv command can normally work.

@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

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.

I too had this issue. What I found is it is a permissions issue. For some unknown reason ownership of my home directory was off. I did a chown -R for the directory I was using for my project making myself the owner of my own directory and now everything works as normal.

If someone encounters this problem inside existing env (when for example using pyenv) you can also use command below (found on GitHub when tried to fix poetry virtual env installation):

pip install --force-reinstall virtualenv

I also had same issue, seems installed version has different user level so I followed their doc and below one work for me:

python3 -m virtualenv --help

To create new environment:

python3 -m virtualenv my_env

It means that there are two virtualenv in your system. One is "pip install" by sudo or root, the other may be installed by apt(if you are using ubuntu os) Just uninstall one of them and the error should be fixed.

To fix this on Ubuntu 20.04, I had to uninstall virtualenv from the system: apt remove python3-virtualenv, and reinstall it using pip: pip install --user virtualenv --force-reinstall. I had errors about dependencies conflicts, I fixed them by calling pip install --user ${package} --force-reinstall for every package involved.

I fixed this error by removing all virtualenv and virtualenvwrapper related packages on system and reinstall the virtualenv and virtualenvwrapper with pip with below command(as i use ubuntu, so below only show apt) remove all packages shown in below result

apt list --installed | grep virtualenvwrapper
apt list --installed | grep virtualenvwrapper

install virtualenv virtualenvwrapper with pip

pip install virtualenvwrapper virtualenvwrapper

set ~/.zshrc

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/amd
export VIRTUALENVWRAPPER_SCRIPT=/home/robot/.local/bin/virtualenvwrapper.sh
export VIRTUALENVWRAPPER_PYTHON=$(which python3)
source /home/robot/.local/bin/virtualenvwrapper.sh

I also faced the same issue but after removing virtualenv which was installed with pip3, I could get rid of this error. Uninstall virtualenv with below command (don't forget to use sudo)

sudo pip3 uninstall virtualenv


After this, virtualenv command works totally fine.

When we use pip3 or python3 to install virtualenv then I got that error too. I had to run each time to create virtualenv (my_env is virtual environment name)

python3 -m virtualenv my_env

But if I install it using

sudo apt install virtualenv

Then virtualenv command works fine.

virtualenv my_env