microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.25k stars 1.15k forks source link

[ms-python.python-2024.4.1 python 3.8.10] Error while creating virtual environment. #23475

Open lmy668 opened 1 month ago

lmy668 commented 1 month ago

1、open recent project 2、 create venv using vscode 3、 select interpreter 3.8.10-64bit 4、 report problem below

2024-05-24 20:42:28.180 [info] Running Env creation script:  [
  'D:\\Program Files\\python\\pyenv-win\\versions\\3.8.10\\python.exe',
  'd:\\Users\\li\\.vscode\\extensions\\ms-python.python-2024.4.1\\python_files\\create_venv.py',
  '--git-ignore'
]
2024-05-24 20:42:28.180 [info] > "D:\Program Files\python\pyenv-win\versions\3.8.10\python.exe" ~\.vscode\extensions\ms-python.python-2024.4.1\python_files\create_venv.py --git-ignore
2024-05-24 20:42:28.180 [info] cwd: .
2024-05-24 20:42:28.645 [info] Running: D:\Program Files\python\pyenv-win\versions\3.8.10\python.exe -m venv .venv
2024-05-24 20:42:29.018 [info] Error: Command '['e:\\Python\\chatgpt-on-wechat\\.venv\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 101.
2024-05-24 20:42:29.026 [info] Traceback (most recent call last):
  File "d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\create_venv.py", line 84, in run_process
2024-05-24 20:42:29.026 [info]     subprocess.run(args, cwd=os.getcwd(), check=True)
  File "D:\Program Files\python\pyenv-win\versions\3.8.10\lib\subprocess.py", line 516, in run
2024-05-24 20:42:29.038 [info]     raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['D:\\Program Files\\python\\pyenv-win\\versions\\3.8.10\\python.exe', '-m', 'venv', '.venv']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\create_venv.py", line 250, in <module>
2024-05-24 20:42:29.039 [info]     main(sys.argv[1:])
  File "d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\create_venv.py", line 219, in main
    run_process(
  File "d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\create_venv.py", line 86, in run_process
2024-05-24 20:42:29.040 [info]     raise VenvError(error_message)
__main__.VenvError: CREATE_VENV.VENV_FAILED_CREATION
2024-05-24 20:42:29.054 [error] Error while running venv creation script:  CREATE_VENV.VENV_FAILED_CREATION
2024-05-24 20:42:29.055 [error] CREATE_VENV.VENV_FAILED_CREATION
2024-05-24 20:42:30.115 [info] > .\.venv\Scripts\python.exe -I ~\.vscode\extensions\ms-python.python-2024.4.1\python_files\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2024.4.1\python_files\interpreterInfo.py
2024-05-24 20:42:30.170 [error] [Error: Command failed: e:\Python\chatgpt-on-wechat\.venv\Scripts\python.exe -I d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\get_output_via_markers.py d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\interpreterInfo.py
Unable to create process using 'D:\Program Files\python\pyenv-win\versions\3.8.10\python.exe -I d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\get_output_via_markers.py d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\interpreterInfo.py'

    at ChildProcess.exithandler (node:child_process:420:12)
    at ChildProcess.emit (node:events:526:35)
    at maybeClose (node:internal/child_process:1091:16)
    at Process.onexit (node:internal/child_process:302:5)] {
  code: 101,
  killed: false,
  signal: null,
  cmd: 'e:\\Python\\chatgpt-on-wechat\\.venv\\Scripts\\python.exe -I d:\\Users\\li\\.vscode\\extensions\\ms-python.python-2024.4.1\\python_files\\get_output_via_markers.py d:\\Users\\li\\.vscode\\extensions\\ms-python.python-2024.4.1\\python_files\\interpreterInfo.py'
}
2024-05-24 20:42:32.181 [info] > .\.venv\Scripts\python.exe -I ~\.vscode\extensions\ms-python.python-2024.4.1\python_files\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2024.4.1\python_files\interpreterInfo.py
2024-05-24 20:42:32.226 [error] [Error: Command failed: e:\Python\chatgpt-on-wechat\.venv\Scripts\python.exe -I d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\get_output_via_markers.py d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\interpreterInfo.py
Unable to create process using 'D:\Program Files\python\pyenv-win\versions\3.8.10\python.exe -I d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\get_output_via_markers.py d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\interpreterInfo.py'

    at ChildProcess.exithandler (node:child_process:420:12)
    at ChildProcess.emit (node:events:526:35)
    at maybeClose (node:internal/child_process:1091:16)
    at Process.onexit (node:internal/child_process:302:5)] {
  code: 101,
  killed: false,
  signal: null,
  cmd: 'e:\\Python\\chatgpt-on-wechat\\.venv\\Scripts\\python.exe -I d:\\Users\\li\\.vscode\\extensions\\ms-python.python-2024.4.1\\python_files\\get_output_via_markers.py d:\\Users\\li\\.vscode\\extensions\\ms-python.python-2024.4.1\\python_files\\interpreterInfo.py'
}
karthiknadig commented 1 month ago

@lmy668 This looks like you might have some issues with the pyenv installed python. This actually has nothing to do with the python extension, it is just not able to create environment using that python, try running this manually to see if it works, from a terminal:

D:\Program Files\python\pyenv-win\versions\3.8.10\python.exe -m venv .venv
lmy668 commented 1 month ago

@karthiknadig thanks, the detail below running command in cmd.

E:\Python\chatgpt-on-wechat>"D:\Program Files\python\pyenv-win\versions\3.8.10\python.exe" -m venv .venv               
Error: Command '['E:\\Python\\chatgpt-on-wechat\\.venv\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 101.

yes, it raises problem. and it create this directory .env, but this content is uncompleted

in addition, i try to run this command, it seems to be normal. but i do not run this manually each time. if python version is 3.7.0, it is successful to create venv using vscode.

E:\Python\chatgpt-on-wechat>"D:\Program Files\python\pyenv-win\versions\3.8.10\python.exe" -m venv .venv --without-pip
E:\Python\chatgpt-on-wechat>
karthiknadig commented 1 month ago

Would it be possible to try and uninstall the 3.8 from pyenv and try and install it again? There might be something wrong with the environment. Typically, the pip issue occurred on Linux where you have to explicitly install it. But on windows it is usually available, so I am assuming there is some issue in the 3.8 install.

lmy668 commented 1 month ago

yes, i just uninstall and reinstall 3.8.10 from pyenv on windows, it still has same problems. Do not 3.8+ support venv?

E:\Python\chatgpt-on-wechat>pyenv --version
The system cannot find the path specified.
pyenv 3.1.1
2024-05-25 12:33:04.266 [info] > "D:\Program Files\python\pyenv-win\versions\3.8.10\python.exe" ~\.vscode\extensions\ms-python.python-2024.4.1\python_files\create_venv.py --git-ignore
2024-05-25 12:33:04.266 [info] cwd: .
2024-05-25 12:33:04.495 [info] Running: D:\Program Files\python\pyenv-win\versions\3.8.10\python.exe -m venv .venv
2024-05-25 12:33:04.705 [info] Error: Command '['e:\\Python\\chatgpt-on-wechat\\.venv\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 101.
2024-05-25 12:33:04.712 [info] Traceback (most recent call last):
  File "d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\create_venv.py", line 84, in run_process
2024-05-25 12:33:04.712 [info]     subprocess.run(args, cwd=os.getcwd(), check=True)
  File "D:\Program Files\python\pyenv-win\versions\3.8.10\lib\subprocess.py", line 516, in run
2024-05-25 12:33:04.712 [info]     raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['D:\\Program Files\\python\\pyenv-win\\versions\\3.8.10\\python.exe', '-m', 'venv', '.venv']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\create_venv.py", line 250, in <module>
2024-05-25 12:33:04.713 [info]     main(sys.argv[1:])
  File "d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\create_venv.py", line 219, in main
2024-05-25 12:33:04.714 [info]     run_process(
  File "d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\create_venv.py", line 86, in run_process
    raise VenvError(error_message)
__main__.VenvError: CREATE_VENV.VENV_FAILED_CREATION
2024-05-25 12:33:04.729 [error] Error while running venv creation script:  CREATE_VENV.VENV_FAILED_CREATION
2024-05-25 12:33:04.729 [error] CREATE_VENV.VENV_FAILED_CREATION
2024-05-25 12:33:05.870 [info] > .\.venv\Scripts\python.exe -I ~\.vscode\extensions\ms-python.python-2024.4.1\python_files\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2024.4.1\python_files\interpreterInfo.py
2024-05-25 12:33:05.920 [error] [Error: Command failed: e:\Python\chatgpt-on-wechat\.venv\Scripts\python.exe -I d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\get_output_via_markers.py d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\interpreterInfo.py
Unable to create process using 'D:\Program Files\python\pyenv-win\versions\3.8.10\python.exe -I d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\get_output_via_markers.py d:\Users\li\.vscode\extensions\ms-python.python-2024.4.1\python_files\interpreterInfo.py'