32

I triyed to execute pipenv shell in a new environtment and I got the following error:

Loading .env environment variables…
Creating a virtualenv for this project…
Using /home/user/.pyenv/shims/python3.9 (3.9.7) to create virtualenv…
⠋ModuleNotFoundError: No module named 'virtualenv.activation.xonsh'
Error while trying to remove the /home/user/.local/share/virtualenvs/7t env: 
No such file or directory

Virtualenv location: 
Warning: Your Pipfile requires python_version 3.9, but you are using None (/bin/python).
  $ pipenv check will surely fail.
Spawning environment shell (/usr/bin/zsh). Use 'exit' to leave.

I tried to remove pipenv, install python with pienv create an alias to python, but anything works.

Any idea, I got the same error in existing environment, I tried to remove all environments folder but nothing.

Thanks.

4 Answers 4

64

Removing the virtualenv pip package worked for me (on Ubuntu WSL)

pip uninstall virtualenv
1
  • 1
    It works but I had to use: pip3.9 uninstall virtualenv Other people having multiple python version on their system might encounter the same issue.
    – Ajite
    Commented May 6, 2022 at 2:21
20

By github issue, the solution that works was the following:

sudo apt-get remove python3-virtualenv
1
  • 1
    It is unclear why this is the solution though? Seems un-intuitive to install the very package that provides the required dependency? Commented Mar 5, 2023 at 7:09
4

I had the same error when updating from Python 3.7 to 3.9 in my pyproject.toml:

[tool.poetry.dependencies]
- python = "^3.7"
+ python = "^3.9"

The cause for me was that I had not installed python3.9-venv yet. Easy:

sudo apt install python3.9-venv

Check with

python3.9 -m venv

OS: Ubuntu 21.10, so your package name might differ

4

I'm on a Mac (with Homebrew + Pyenv) and unfortunately none of the other solutions helped. It turned out that even though pipenv appeared to run ok, the Pipenv install itself was somehow incomplete/corrupted. Doing

pip install pipenv

fixed it for me. To do a more thorough reinstall if the above doesn't fix it, you can also try

pip install --force-reinstall pipenv
1
  • Adding to this: I had pipenv installed at the system and user level. Uninstalling both, then force reinstall fixed my issue. I think it had something to do with mismatched dependency versions. Commented Sep 16, 2022 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.