1

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:\Users\Alnourrus\Desktop\cfeproj\Pipfile
Using C:/Program Files/Python39/python.exe (3.9.1) to create virtualenv...
[   =] Creating virtual environment...New python executable in C:\Users\Alnourrus\.virtualenvs\cfeproj-gGpEVtIi\Scripts\python.exe
ERROR: The executable C:\Users\Alnourrus\.virtualenvs\cfeproj-gGpEVtIi\Scripts\python.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 files\python39\lib\site-packages\virtualenv.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:\Users\Alnourrus\.virtualenvs\cfeproj-gGpEVtIi\lib\site.py", line 67, in <module>
    import os
  File "C:\Users\Alnourrus\.virtualenvs\cfeproj-gGpEVtIi\lib\os.py", line 29, in <module>
    from _collections_abc import _check_methods
ModuleNotFoundError: No module named '_collections_abc'

Failed to create virtual environment.
SiHa
  • 7,830
  • 13
  • 34
  • 43
saifdeeb
  • 11
  • 1
  • Have you found a solution to this? I'm wondering if this is a similar issue to what I'm experiencing. However, I'm on a mac and trying to use pybuilder. Maybe a problem with virtualenv and python 3.9.1? I posted my issue here: https://stackoverflow.com/questions/65546955/after-initiating-a-pybuilder-project-i-receive-an-error-that-the-executable-is-n – Brod Jan 05 '21 at 06:06

2 Answers2

0

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/
Nima
  • 122
  • 6
0

use python -m when creating a pipenv environment

sahasrara62
  • 10,069
  • 3
  • 29
  • 44