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.

1
  • 3
    Solved. It is a bug when debug binaries are installed. See bugs.python.org/issue36441 Commented Mar 28, 2019 at 16:01

8 Answers 8

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

Sign up to request clarification or add additional context in comments.

Comments

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.

1 Comment

I just gave a try to Python 3.7.4rc1 and this issue is gone
4

In Anaconda prompt type these commands:

conda remove anaconda
conda update python
conda list --show-channel-urls | findstr python
python -m venv venv

Comments

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 ;)

Comments

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

Comments

1

These steps worked for me

conda update --force conda
conda update python
conda list --show-channel-urls | findstr python
python -m venv venv

Comments

0

I update python and bug fixed

conda update --force conda

Comments

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."

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.