Ahadu Tsegaye Abebe
Ahadu Tsegaye Abebe

Reputation: 724

pipenv install error ImportError: cannot import name 'ensure_file_on_disk'

I'm trying to create a python virtual environment with pipenv 2018.11.26 on Windows [Version 10.0.14393] and Python 3.5.2 (Anaconda 4.1.1 (64-bit)). These are all mandatory settings that I can't alter.

I get the following cryptic error:

C:\project_path\pipenv install

Creating a virtualenv for this project…
Pipfile: C:\project_path\Pipfile
Using C:/Anaconda3/pythonw.exe (3.5.2) to create virtualenv…
[  ==] Creating virtual environment...ImportError: cannot import name 'ensure_file_on_disk'

Failed creating virtual environment
[pipenv.exceptions.VirtualenvCreationException]:   File "c:\anaconda3\lib\site-        packages\pipenv\cli\command.py", line 254, in install
[pipenv.exceptions.VirtualenvCreationException]:           editable_packages=state.installstate.editables,
[pipenv.exceptions.VirtualenvCreationException]:   File "c:\anaconda3\lib\site-    packages\pipenv\core.py", line 1741, in do_install
[pipenv.exceptions.VirtualenvCreationException]:       pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]:   File "c:\anaconda3\lib\site-    packages\pipenv\core.py", line 574, in ensure_project
[pipenv.exceptions.VirtualenvCreationException]:       pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]:   File "c:\anaconda3\lib\site-    packages\pipenv\core.py", line 506, in ensure_virtualenv
[pipenv.exceptions.VirtualenvCreationException]:       python=python, site_packages=site_packages,     pypi_mirror=pypi_mirror
[pipenv.exceptions.VirtualenvCreationException]:   File "c:\anaconda3\lib\site-    packages\pipenv\core.py", line 935, in do_create_virtualenv
[pipenv.exceptions.VirtualenvCreationException]:       extra=[crayons.blue("{0}".format(c.err)),]
[pipenv.exceptions.VirtualenvCreationException]:
Failed to create virtual environment.

The main cause sees to be an import error, but I can't find anything called ensure_file_on_disk.

I have tried to uninstall and re-install pipenv to no avail.

Also, since I'm running behind a proxy, I have created the system environment variables no_proxy, http_proxy and https_proxy but it hasn't worked either.

By the way if I try to run pipenv shell it gives me the exact same error, so it does not seem to be a connection problem after all.

Have you guys ever come across this issue?

Thanks

Upvotes: 7

Views: 10653

Answers (5)

Nunespace
Nunespace

Reputation: 1

This is a version issue. On Windows, I typed the following commands:

> py -m ensurepip --upgrade
> py -m pip install --upgrade pip
> py -m pip install --upgrade pipenv

And it works!

Upvotes: 0

Богдан Лис
Богдан Лис

Reputation: 1

In my case updating pip helped

python3.6 -m pip install --upgrade pip

next uninstall virtualenv

python3.6 -m pip uninstall virtualenv

and install it

python3.6 -m pip install virtualenv

Upvotes: 0

Vinay Namadi
Vinay Namadi

Reputation: 99

I resolved this issue. In my case, it is because of multiple versions of virtualenv are installed. I removed all the versions using pip3 uninstall virtualenv multiple times. Thereafter I've installed the latest virtualenv again.

Upvotes: 6

Cristian M
Cristian M

Reputation: 17

pip3 install --user --upgrade cython virtualenv==20.0.28

Upvotes: -1

Ahadu Tsegaye Abebe
Ahadu Tsegaye Abebe

Reputation: 724

I solved the issue by uninstalling the virtualenv package and reinstalling a compatible version which I found to be 20.0.25

Upvotes: 2

Related Questions