dorriz
dorriz

Reputation: 2679

pipenv fails to create a virtual environment

I am running Ubuntu on Windows Subsystem For Linux (WSL).

I open my VSCode using Ubuntu code in the terminal.

I have Python 3.8.2, pip 20.0.2 and pipenv version 2020.6.2 installed.

I create a folder or my Python project and cd into it.

I type 'pipenv shell'.

I get the following error:

Creating a virtualenv for this project…
Pipfile: /home/user/Python/ExampleOne/Pipfile
Using /usr/bin/python3 (3.8.2) to create virtualenv…
⠋ Creating virtual environment...ModuleNotFoundError: No module named 'virtualenv.seed.via_app_data'

✘ Failed creating virtual environment 

I do not seem to be able to find any information on the issue to resolve it. How can I solve this issue or where might I look to understand it better?

Upvotes: 3

Views: 8616

Answers (3)

Bodhisha
Bodhisha

Reputation: 41

Downgrading the virtulenv version to 20.0.23 solves the problem for me

pip install virtualenv==20.0.23

Source : https://github.com/pypa/virtualenv/issues/1873

Upvotes: 4

user419164
user419164

Reputation: 101

I have it working on a setup identical to yours (WSL1 running Ubuntu 20.04, pip 20.0.2, python 3.8.2, pipenv 2020.6.2). However, I also figured out how to replicate your problem so I think I know what's going on here. The error is actually a problem with virtualenv not pipenv itself (pipenv is built on virtualenv). You can verify this by trying to create a virtual env instead:

virtualenv my_env

or:

python -m virtualenv my_env

You should get the same error. This is only a problem in WSL and not in normal Ubuntu and it has to do with Window's path length limit (see this github issue). Luckily, if you install pipenv with pip instead of apt, it will use a shorter path that windows can deal with. Try this:

sudo apt autoremove pipenv
pip install pipenv

Now try to create your pipenv. Hopefully this solves your problem. It worked for me.

Upvotes: 8

Dhwanil Patel
Dhwanil Patel

Reputation: 11

Try:

pipenv install --python=/usr/bin/python3.6
pipenv --python /usr/bin/python3

Explanation: https://github.com/pypa/pipenv/issues/3488.

Upvotes: 1

Related Questions