Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
666 views
in Technique[技术] by (71.8m points)

python - pipenv fails installing Django

I'm trying to create virtual environment in PowerShell with Python 3.9, using the pipenv command, but when I run pipenv install Django it says this:

Creating a virtualenv for this project...
Pipfile: C:UsersAlnourrusDesktopcfeprojPipfile
Using C:/Program Files/Python39/python.exe (3.9.1) to create virtualenv...
[   =] Creating virtual environment...New python executable in C:UsersAlnourrus.virtualenvscfeproj-gGpEVtIiScriptspython.exe
ERROR: The executable C:UsersAlnourrus.virtualenvscfeproj-gGpEVtIiScriptspython.exe is not functioning
ERROR: It thinks sys.prefix is 'c:\users\alnourrus\desktop\cfeproj' (should be 'c:\users\alnourrus\.virtualenvs\cfeproj-ggpevtii')
ERROR: virtualenv is not compatible with this system or executable
Note: some Windows users have reported this error when they installed Python for "Only this user" or have multiple versions of Python installed. Copying the appropriate PythonXX.dll to the virtualenv Scripts/ directory may fix this problem.
Running virtualenv with interpreter C:/Program Files/Python39/python.exe

Failed creating virtual environment

[pipenv.exceptions.VirtualenvCreationException]: c:program filespython39libsite-packagesvirtualenv.py:1137: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
  File "C:UsersAlnourrus.virtualenvscfeproj-gGpEVtIilibsite.py", line 67, in <module>
    import os
  File "C:UsersAlnourrus.virtualenvscfeproj-gGpEVtIilibos.py", line 29, in <module>
    from _collections_abc import _check_methods
ModuleNotFoundError: No module named '_collections_abc'

Failed to create virtual environment.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It appears pipenv is crashing because it attempts to create a folder that already exists. Try clearing the virtual env with

rm -rf `pipenv --venv`

If that fails because pipenv complains there isn't an associated virtualenv, you'll have to skip the shortcuts and look at the error message for what folder it doesn't like and delete it ( make sure you're deleting a subfolder of /virtualenvs and not something important like the pipenv bin )

rm -rf /Users/juyeong/.local/share/virtualenvs/django_workspace-CfQ2tbWB/

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...