Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot select 2.7 as interpreter #20637

Closed
phantasm opened this issue Feb 3, 2023 · 8 comments
Closed

Cannot select 2.7 as interpreter #20637

phantasm opened this issue Feb 3, 2023 · 8 comments
Assignees
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on regression Bug didn't exist in a previous release verified Verification succeeded
Milestone

Comments

@phantasm
Copy link

phantasm commented Feb 3, 2023

Type: Bug

Behaviour

Expected vs. Actual

Expected: select Python 2.7.18 interpreter from drop-down list (via browsing)

Actual: nothing happens and yellow button "Select interpreter" is still displayed in the status bar. Latest vscode-python version which works fine is 2022.18.2. Any recent version have this bug. I didn't notice any warnings about dropping 2.7 completely in release notes, and hope it won't happen :)

Steps to reproduce:

Try to select Python 2.7.18 interpreter from drop-down list - browse to its folder and select python.exe

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 2.7.18
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Unknown
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Experiment 'pythonaacf' is active
LSP Notebooks experiment is enabled
LSP Notebooks interactive window support is enabled
> conda info --json
> c:\Python27\python.exe -I ~\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\interpreterInfo.py
> C:\Python3\python.exe -I ~\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\interpreterInfo.py
[ERROR 2023-1-3 4:14:12.83]: [Error: Command failed: c:\Python27\python.exe -I c:\Users\phantasm\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\get_output_via_markers.py c:\Users\phantasm\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\interpreterInfo.py
Unknown option: -I
usage: c:\Python27\python.exe [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.

	at ChildProcess.exithandler (node:child_process:408:12)
	at ChildProcess.emit (node:events:526:28)
	at maybeClose (node:internal/child_process:1092:16)
	at Socket.<anonymous> (node:internal/child_process:451:11)
	at Socket.emit (node:events:526:28)
	at Pipe.<anonymous> (node:net:687:12)] {
  killed: false,
  code: 2,
  signal: null,
  cmd: 'c:\\Python27\\python.exe -I c:\\Users\\phantasm\\.vscode\\extensions\\ms-python.python-2023.2.0\\pythonFiles\\get_output_via_markers.py c:\\Users\\phantasm\\.vscode\\extensions\\ms-python.python-2023.2.0\\pythonFiles\\interpreterInfo.py'
}
> c:\Python27\python.exe -I ~\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\interpreterInfo.py
[ERROR 2023-1-3 4:14:14.136]: [Error: Command failed: c:\Python27\python.exe -I c:\Users\phantasm\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\get_output_via_markers.py c:\Users\phantasm\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\interpreterInfo.py
Unknown option: -I
usage: c:\Python27\python.exe [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.

	at ChildProcess.exithandler (node:child_process:408:12)
	at ChildProcess.emit (node:events:526:28)
	at maybeClose (node:internal/child_process:1092:16)
	at ChildProcess._handle.onexit (node:internal/child_process:302:5)] {
  killed: false,
  code: 2,
  signal: null,
  cmd: 'c:\\Python27\\python.exe -I c:\\Users\\phantasm\\.vscode\\extensions\\ms-python.python-2023.2.0\\pythonFiles\\get_output_via_markers.py c:\\Users\\phantasm\\.vscode\\extensions\\ms-python.python-2023.2.0\\pythonFiles\\interpreterInfo.py'
}
Starting Pylance language server.

User Settings


languageServer: "Pylance"

Extension version: 2022.18.2
VS Code version: Code 1.75.0 (e2816fe719a4026ffa1ee0189dc89bdfdbafb164, 2023-02-01T15:23:45.584Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Sandboxed: No

System Info
Item Value
CPUs AMD Ryzen 7 5800X3D 8-Core Processor (16 x 3400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) undefined
Memory (System) 15.92GB (4.49GB free)
Process Argv --crash-reporter-id 4d41d7e4-4df1-46cd-80fe-eb31c1916345
Screen Reader no
VM 67%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vsdfh931:30280409
vshan820:30294714
vstes263cf:30335440
vscorecescf:30445987
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593:30376534
pythonvs932:30410667
cppdebug:30492333
vscaac:30438847
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
azure-dev_surveyone:30548225
pyindex848:30577860
nodejswelcome1cf:30587006
3biah626:30602489
pyind779:30657576
89544117:30613380
pythonsymbol12cf:30657549
vscup:30628656

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 3, 2023
@cesarcoatl
Copy link

Seeing the same behavior on macOS but not on Windows, running the latest versions of vscode and the Python extension.

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Experiment 'pythonSurveyNotification' is active
LSP Notebooks experiment is disabled -- Jupyter disabled or not installed
LSP Notebooks interactive window support is disabled -- not in LSP Notebooks experiment
> ~/.pyenv/versions/2.7.18/envs/ignition-api/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
[ERROR 2023-1-2 17:34:34.36]: Error: Command failed: /Users/thecesrom/.pyenv/versions/2.7.18/envs/ignition-api/bin/python -I /Users/thecesrom/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py /Users/thecesrom/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
Unknown option: -I
usage: /Users/thecesrom/.pyenv/versions/2.7.18/envs/ignition-api/bin/python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.

    at ChildProcess.exithandler (node:child_process:408:12)
    at ChildProcess.emit (node:events:526:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Socket.<anonymous> (node:internal/child_process:451:11)
    at Socket.emit (node:events:526:28)
    at Pipe.<anonymous> (node:net:687:12) {
  killed: false,
  code: 2,
  signal: null,
  cmd: '/Users/thecesrom/.pyenv/versions/2.7.18/envs/ignition-api/bin/python -I /Users/thecesrom/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py /Users/thecesrom/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py'
}
> ~/.pyenv/versions/2.7.18/envs/ignition-api/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
[ERROR 2023-1-2 17:34:36.48]: Error: Command failed: /Users/thecesrom/.pyenv/versions/2.7.18/envs/ignition-api/bin/python -I /Users/thecesrom/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py /Users/thecesrom/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
Unknown option: -I
usage: /Users/thecesrom/.pyenv/versions/2.7.18/envs/ignition-api/bin/python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.

    at ChildProcess.exithandler (node:child_process:408:12)
    at ChildProcess.emit (node:events:526:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Socket.<anonymous> (node:internal/child_process:451:11)
    at Socket.emit (node:events:526:28)
    at Pipe.<anonymous> (node:net:687:12) {
  killed: false,
  code: 2,
  signal: null,
  cmd: '/Users/thecesrom/.pyenv/versions/2.7.18/envs/ignition-api/bin/python -I /Users/thecesrom/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py /Users/thecesrom/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py'
}
Starting Pylance language server.

@phantasm
Copy link
Author

phantasm commented Feb 3, 2023

commandline option -I is used to isolate Python from the user's environment (implies -E and -s), but it doesn't exist in python2, only in python3. It seems to me that it may be possible to replace -I option back to -E -s and see what happens

@karthiknadig
Copy link
Member

Python extension dropped support for python 2.7 a while ago. As underlying tools and libraries we depend on move forward, it is likely that this will stop working for unsupported versions.

If you need to work with python 2.7 you will have to pin to 2022.2.* version of the extension, which was the last version that had the debugger (debugpy) with support for python 2.7, and was tested with 2.7.

@karrtikr
Copy link

karrtikr commented Feb 4, 2023

FYI we have temporarily restored the ability to select Python 2.7 as an interpreter in pre-release, try it out:

image

However do note not all features are guaranteed to work properly so upgrade as soon as possible.

@phantasm
Copy link
Author

phantasm commented Feb 4, 2023

@karrtikr seems to work now, but
image

Pylance doesn't want to use 2.7 as interpreter too. I've tried most of the old versions but no luck. Recent versions always use python3, older ones say "Python version 2.7 from interpreter is unsupported".

P.S. I'll be glad to move to python3, but now it's impossible - about 1M lines of code so I'm stuck with 2.7

@karrtikr karrtikr added bug Issue identified by VS Code Team member as probable bug regression Bug didn't exist in a previous release area-environments Features relating to handling interpreter environments verified Verification succeeded needs PR Ready to be worked on and removed triage-needed Needs assignment to the proper sub-team labels Feb 4, 2023
@karrtikr karrtikr self-assigned this Feb 4, 2023
@karrtikr karrtikr added this to the February 2023 milestone Feb 4, 2023
@karrtikr
Copy link

karrtikr commented Feb 4, 2023

@phantasm Try Jedi, set python.languageServer setting to "Jedi". Unfortunately there aren't many workarounds for now other than rolling back and using older versions.

@phantasm
Copy link
Author

phantasm commented Feb 4, 2023

@karrtikr that's sad. jedi for 2.7 doesn't have intellisense so it's better to see some pylance errors than not having intellisense at all. sigh

thank you for your efforts anyway!

@cesarcoatl
Copy link

I understand that the only option is to move forward, and I'm at peace with not getting all of the features. But since I am maintaining Jython applications Python 2.7 is my only option.

Thanks as well, @karrtikr.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on regression Bug didn't exist in a previous release verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants