I’ve been trying for hours to solve my problem which basically is that I can’t create a virtual environment in VSCode with python version 2.X.
I’ve read that the problem is that the new versions of the python extension for vscode no longer allow creating virtual environments for python 2. If I remember correctly, 2 months ago I was still able to create an environment for python 2 and without any problem.
I have pyenv installed on windows with different versions of python, including 2.7.18 and some versions 3.x.x. The problem is that with versions 3 there are no errors and with version 2, it doesn’t allow me to create the virtual environment, i use venv not conda.
I get the following error:
<code>2024-08-17 18:40:37.630 [info] Selected interpreter C:UsersAlienware.pyenvpyenv-winversions2.7.18python.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',
2024-08-17 18:40:37.746 [info] > ~.pyenvpyenv-winversions2.7.18python.exe ~.vscodeextensionsms-python.python-2024.13.2024081501-win32-x64python_filescreate_venv.py --git-ignore
2024-08-17 18:40:37.746 [info] cwd: .
2024-08-17 18:40:37.847 [info] File "c:UsersAlienware.vscodeextensionsms-python.python-2024.13.2024081501-win32-x64python_filescreate_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
<code>2024-08-17 18:40:37.630 [info] Selected interpreter C:UsersAlienware.pyenvpyenv-winversions2.7.18python.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] > ~.pyenvpyenv-winversions2.7.18python.exe ~.vscodeextensionsms-python.python-2024.13.2024081501-win32-x64python_filescreate_venv.py --git-ignore
2024-08-17 18:40:37.746 [info] cwd: .
2024-08-17 18:40:37.847 [info] File "c:UsersAlienware.vscodeextensionsms-python.python-2024.13.2024081501-win32-x64python_filescreate_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
</code>
2024-08-17 18:40:37.630 [info] Selected interpreter C:UsersAlienware.pyenvpyenv-winversions2.7.18python.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] > ~.pyenvpyenv-winversions2.7.18python.exe ~.vscodeextensionsms-python.python-2024.13.2024081501-win32-x64python_filescreate_venv.py --git-ignore
2024-08-17 18:40:37.746 [info] cwd: .
2024-08-17 18:40:37.847 [info] File "c:UsersAlienware.vscodeextensionsms-python.python-2024.13.2024081501-win32-x64python_filescreate_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
Is there any solution to be able to create venv from vscode for 2.x versions?