Search code examples
pythonanacondavirtualenvpipenv

Failed to create a virtual environment using pipenv inside a conda Python 3.8.3 environment on Windows


System and environment details:
Anaconda based python environment on a Windows 10 PC
conda 4.8.5
Python 3.8.3
pipenv version 2020.8.13

I wish to launch a virtual environment for a new project, install the dependencies inside that virtual environment and run the code. The project is located in the code/ directory on my PC. I installed pipenv in my PC for creating a virtual environment using pip install pipenv. To create a virtual environment using pipenv, I executed the command pipenv shell from the root of my project directory (code) and got the following output.

$ pipenv shell
Creating a virtualenv for this project...
Pipfile: C:\Users\myPC\code\Pipfile
Using C:/Users/myPC/Anaconda3/python.exe (3.8.3) to create virtualenv...
[==  ] Creating virtual environment...FileNotFoundError: [Errno 2] No such file or directory: 'c:\\users\\myPC\\anaconda3\\Lib\\venv\\scripts\\nt\\python.exe'

Failed creating virtual environment

[pipenv.exceptions.VirtualenvCreationException]:
Failed to create virtual environment.

The python executable being pointed to in the output above i.e., C:/Users/myPC/Anaconda3/python.exe (3.8.3) is the place where Anaconda is installed in my PC, so this seems to be fine. However, I do not understand what file it is looking for in the last line of the output.


Solution

  • I was able to solve this issue myself by referring the solution mentioned in this github issue. Although, this seems to be a workaround for the moment but nevertheless, it works.

    I manually copied the python.exe and pythonw.exe from C:/Users/myPC/Anaconda3/ directory into c:\users\myPC\anaconda3\Lib\venv\scripts\nt\