I want to create a virtual environment in VS Code with python version 2.X. If I remember correctly, I was able to create an environment for Python 2 two months ago, but I can't do so anymore.
I've read that the problem is that the new versions of the Python extension for VS Code no longer allow creating virtual environments for python 2.
I have pyenv installed on windows with different versions of python, including 2.7.18 and some versions 3.x.x. Python 3 works fine, creating a virtual environment using Python 2 throws the following error:
2024-08-17 18:40:37.630 [info] Selected interpreter C:\Users\Alienware\.pyenv\pyenv-win\versions\2.7.18\python.exe for creating virtual environment.
2024-08-17 18:40:37.746 [info] Running Env creation script: [
'C:\\Users\\Alienware\\.pyenv\\pyenv-win\\versions\\2.7.18\\python.exe',
'c:\\Users\\Alienware\\.vscode\\extensions\\ms-python.python-2024.13.2024081501-win32-x64\\python_files\\create_venv.py',
'--git-ignore'
]
2024-08-17 18:40:37.746 [info] > ~\.pyenv\pyenv-win\versions\2.7.18\python.exe ~\.vscode\extensions\ms-python.python-2024.13.2024081501-win32-x64\python_files\create_venv.py --git-ignore
2024-08-17 18:40:37.746 [info] cwd: .
2024-08-17 18:40:37.847 [info] File "c:\Users\Alienware\.vscode\extensions\ms-python.python-2024.13.2024081501-win32-x64\python_files\create_venv.py", line 23
def parse_args(argv: Sequence[str]) -> argparse.Namespace:
2024-08-17 18:40:37.847 [info] ^
SyntaxError: invalid syntax
2024-08-17 18:40:37.849 [error] Error while running venv creation script: undefined
2024-08-17 18:40:37.850 [error] Failed to create virtual environment with exitCode: 1
I'm currently following these steps:
Install pyenv for windows following this guide: https://github.com/pyenv-win/pyenv-win#quick-start
Install this version of python:
Set python 2.7.18 as global interpreter with "pyenv global 2.7.18"
Download and installing vscode with python extension v2024.13.2024081501 (pre-release)
Create a new workspace in vscode and create a new venv with CTRL + SHIFT + P:
- Error (interpreter already selected):
- Console output:
Is it possible to create venv from vscode for 2.x versions?



