skip to Main Content

I have VS Code (v. 1.84.2) along with the Python extension (v2023.20.0). I’m trying to set up a virtual environment with the following steps:

  1. I typed Ctrl-Shift-P to open the Command Palette.
  2. I selected "Python: Create Environment…" from the drop-down menu.
  3. I selected ‘Venv’ as the type of environment.
  4. I selected "Python 3.12.0 64-bit" as my Python installation.

When I do that I get this error:

CREATE_VENV.VENV_NOT_FOUND

How do I solve this?

Here is the output:

2023-11-22 09:25:10.912 [info] Selected workspace c:UsersMEsourcepython_projectspython-testing for creating virtual environment.
2023-11-22 09:25:14.752 [info] Selected interpreter C:UsersMEsourcepythonpython.exe for creating virtual environment.
2023-11-22 09:25:14.833 [info] Running Env creation script:  [
  'C:\Users\ME\source\Developers\Projects\python\python.exe',
  'c:\Users\ME\.vscode\extensions\ms-python.python-2023.20.0\pythonFiles\create_venv.py',
  '--git-ignore'
]
2023-11-22 09:25:14.833 [info] > ~sourcepythonpython.exe ~.vscodeextensionsms-python.python-2023.20.0pythonFilescreate_venv.py --git-ignore
2023-11-22 09:25:14.833 [info] cwd: .
2023-11-22 09:25:15.255 [info] Traceback (most recent call last):
  File "c:UsersME.vscodeextensionsms-python.python-2023.20.0pythonFilescreate_venv.py", line 250, in <module>
2023-11-22 09:25:15.256 [info]     main(sys.argv[1:])
  File "c:UsersME.vscodeextensionsms-python.python-2023.20.0pythonFilescreate_venv.py", line 185, in main
    raise VenvError("CREATE_VENV.VENV_NOT_FOUND")
VenvError: CREATE_VENV.VENV_NOT_FOUND
2023-11-22 09:25:15.291 [error] Error while running venv creation script:  CREATE_VENV.VENV_NOT_FOUND
2023-11-22 09:25:15.292 [error] CREATE_VENV.VENV_NOT_FOUND

2

Answers


  1. Chosen as BEST ANSWER

    It turns out that my company forbids the installation of applications on user desktops, unless it's an approved application (Python is not). So I'll try reinstalling Python once it gets approved. That should resolve the errors I was getting.


  2. That error comes up if you don’t have the ‘venv’ library/module installed.

    Try just going to a terminal and doing a python -m venv test_venv and see if you get an error.

    Or, try by opening a python terminal and doing

    import importlib.util as import_util
    import_util.find_spec('venv')
    

    If that prints out a bunch of info like ModuleSpec(name=’venv’….), then you have venv installed. If it doesn’t, then you don’t have venv installed.

    If you don’t have venv installed, I’d recommend reinstalling python.


    The error message gave you a filepath where the error originates from, which was "c:UsersME.vscodeextensionsms-python.python-2023.20.0pythonFilescreate_venv.py". We can open this and read it like any other python file, and see read the lines that generate the exception ‘CREATE_VENV.VENV_NOT_FOUND’. They are specifically using the importlib.util method I gave above to determine if they raise the error.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search