21

I'm using the latest version of Python on Windows and I'm trying to use venv with the following code:

C:\envs> py -m venv test

Even if it actually creates the venv, it returns this error and I don't understand why. Moreover I can't activate the venv, the code

C:\envs> C:\envs\test\Scripts\activate.bat

returns

"C:\envs\test\Scripts\activate.bat" is not recognized as an internal or external command, operable program or batch file.

Giulio Caccin
  • 2,962
  • 6
  • 36
  • 57
Villani
  • 211
  • 1
  • 2
  • 3
  • 3
    Solved. It is a bug when debug binaries are installed. See https://bugs.python.org/issue36441 – Villani Mar 28 '19 at 16:01

8 Answers8

23

I am using python version 3.7.3 it gave me error states that "No such file or directory: 'C:\python37\lib\venv\scripts\nt\python_d.exe'" at the time of creation of project in pycharm.

I copied following files from python location(C:\Program Files\Python37) to the (C:\Program Files\Python37\Lib\venv\scripts\nt) and it worked for me

1) python_d.exe
2) python_d.pdb
3) pythonw_d.exe
4) pythonw_d.pdb

Mohit Bhavsar
  • 371
  • 1
  • 5
8

As Villani mentioned in his own comment, it's a debug binaries problem.

It will be fixed in the upcoming 3.7.4 release. (Planned for 24/06)

Either downgrade to 3.7.2 or install without debug binaries.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
kazaamjt
  • 121
  • 1
  • 7
4

In Anaconda prompt type these commands:

conda remove anaconda
conda update python
conda list --show-channel-urls | findstr python
python -m venv venv
sentence
  • 8,213
  • 4
  • 31
  • 40
2

for me what fixed the issue was copying the python_d.exe and python_d.pdb from C:\Program Files\Python37 to C:\Program Files\Python37\Lib\venv\scripts\nt

hope this solves your problem ;)

2

The problem is , your virtual environment could not find debugger resources. The venv module's resources dont have those resources (probably a bug). The easy solution is.

  1. Fix the venv module resources first: Copy debugger symbols to venv resources. In your python installation directory copy python_d.pdb, python_d.exe, pythonw_d.pdb, pythonw_d.exe and past inside (installation directory) Lib>venv>scripts>nt. In this nt folder should also have (already present) python.exe , python.pdb , pythonw.exe, pythonw.pdb
  2. Now, try to create virtual environment using

    python -m venv py37dev

Shantonu
  • 1,280
  • 13
  • 12
1

These steps worked for me

conda update --force conda
conda update python
conda list --show-channel-urls | findstr python
python -m venv venv
Nav_cfc
  • 154
  • 1
  • 4
  • 15
0

I update python and bug fixed

conda update --force conda
parus
  • 1
0
conda remove anaconda
conda update python
python -m venv venv

This will resolve it but your main Python interpreter will run from the conda environment & it will prompt the error below but it will work just fine.

"This Python interpreter is in a conda environment, but the environment has not been activated."

David Buck
  • 3,752
  • 35
  • 31
  • 35
Raghav
  • 31
  • 2