Search code examples
visual-studio-codepython-venv

Python venv is giving errno 2 in visual studio code


I tried to make a virtual environment as stated in the documentation of the visual studio code. I have already installed python 3.7.3 and anaconda on the system.

I did the following and I'm using vs code version 1.34 and windows 10:

I made an empty folder and used this line of code as stated in official documentation:

py -3 -m venv .venv

I expected a folder named .venv that has scripts folder with 'activate' file in it. As i have tested this method which worked on other systems with the same configuration, But instead i get the below error message:

Error: [Errno 2]: no such file or directory : 'C:\\ProgramData\\Anaconda3\\lib\\venv\\scripts\\nt\\python.exe'

Solution

  • It look like installer is broken, or so...

    Copy from Python 3 installation folder:

    C:\Users{user}\AppData\Local\Programs\Python\Python37

    Files: python.exe, python.pdb, python_d.exe, python_d.pdb, pythonw.exe & pythonw.pdb to folder: C:\ProgramData\Anaconda3\lib\venv\scripts\nt\