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

spawn /usr/bin/python2 ENOENT when trying to select interpreter #1305

Closed
wolf99 opened this issue Apr 5, 2018 · 27 comments · Fixed by #1352
Closed

spawn /usr/bin/python2 ENOENT when trying to select interpreter #1305

wolf99 opened this issue Apr 5, 2018 · 27 comments · Fixed by #1352
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster windows
Milestone

Comments

@wolf99
Copy link

wolf99 commented Apr 5, 2018

spawn /usr/bin/python2 ENOENT

Environment data

  • VS Code version: 1.21.1
  • Extension version (available under the Extensions sidebar): 2018.3.1
  • OS and version: Windows 7 (7601)
  • Python version (& distribution if applicable, e.g. Anaconda): python.org 3.6.5
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): NA
  • Relevant/affected Python packages and their versions: python 3 (as above)

Actual behavior

Step 3 of the prerequisites states:

From within VS Code, select a version of Python using the Python: Select Interpreter command on the Command Palette (Ctrl+Shift+P), or by using the Select Python Environment option on the Status Bar if available

The command presents a list of available interpreters that VS Code can find automatically. If you don't see the desired interpreter, see Configuring Python environments.

The readme also mentions this under optional steps:

Step 5. Select your preferred Python interpreter/version/environment using the Select Interpreter command.

  • By default we use the one that's on your path.
  • If you have a workspace open you can also click in the status bar to change the interpreter.

However, when attempting to select an interpreter, VsCode reports the error:

spawn /usr/bin/python2 ENOENT
and nothing further happens.

Expected behavior

The interpreter is selected (or at least a more helpful error message is displayed)

Steps to reproduce:

  1. Install vscode,
  2. Install python,
  3. Ensure python is on path
  4. Install extension,
  5. Attempt to select interpreter.

Python install path is known by vscode as selecting Python: Start REPL, works as expected.

Logs

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

##########Linting Output - pylint##########
No config file found, using default configuration

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

log.ts:171   ERR spawn /usr/bin/python2 ENOENT: Error: spawn /usr/bin/python2 ENOENT
	at exports._errnoException (util.js:1050:11)
	at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
	at onErrorNT (internal/child_process.js:367:16)
	at _combinedTickCallback (internal/process/next_tick.js:80:11)
	at process._tickCallback (internal/process/next_tick.js:104:9)
console.ts:136 [Extension Host] rejected promise not handled within 1 second
t.log @ console.ts:136
t._logExtensionHostMessage @ extensionHost.ts:400
(anonymous) @ extensionHost.ts:213
emitTwo @ events.js:106
emit @ events.js:194
process.nextTick @ internal/child_process.js:766
_combinedTickCallback @ internal/process/next_tick.js:73
_tickCallback @ internal/process/next_tick.js:104
notificationsAlerts.ts:39 spawn /usr/bin/python2 ENOENT
e.onDidNotificationChange @ notificationsAlerts.ts:39
(anonymous) @ notificationsAlerts.ts:28
e.fire @ event.ts:142
e.notify @ notifications.ts:127
e.error @ notificationService.ts:58
t.onError @ commandsHandler.ts:326
(anonymous) @ commandsHandler.ts:311
done @ winjs.base.raw.js:1391
v @ winjs.base.raw.js:1237
enter @ winjs.base.raw.js:914
_run @ winjs.base.raw.js:1081
_error @ winjs.base.raw.js:1054
e.resolveErr @ lazyPromise.ts:78
e._receiveReplyErr @ rpcProtocol.ts:154
e._receiveOneMessage @ rpcProtocol.ts:99
(anonymous) @ rpcProtocol.ts:33
(anonymous) @ rpcProtocol.ts:213
e.fire @ event.ts:142
(anonymous) @ ipc.net.ts:81
emitOne @ events.js:96
emit @ events.js:191
readableAddChunk @ _stream_readable.js:178
Readable.push @ _stream_readable.js:136
onread @ net.js:560
@brettcannon brettcannon added bug Issue identified by VS Code Team member as probable bug needs verification labels Apr 5, 2018
@brettcannon
Copy link
Member

Can you send us a screenshot of what interpreters are listed by the extension? Since you're on Windows 7 it shouldn't be trying to execute /usr/bin/python2 (especially if you only have Python 3 installed).

@brettcannon brettcannon added info-needed Issue requires more information from poster and removed needs verification labels Apr 5, 2018
@DonJayamanne
Copy link

Also, please let us know how you have started VS Code? (did you lunch it from the bash terminal?)

@wolf99
Copy link
Author

wolf99 commented Apr 5, 2018

@brettcannon I can grab a screenshot in the morning. I have Msys2 installed on the machine and configured such the programs it provides are available on the PATH - I shouldn't think this should affect vscode but it occurred to me to mention it as a possibility.

@DonJayamanne I started vscode as I generally do, via the normal Windows Menu icon as provided by vscode's installer

@bbukaty
Copy link

bbukaty commented Apr 8, 2018

Also having this problem, I think it might have something to do with the linux subsystem for win10, but I uninstalled it and the problem persisted.

@DonJayamanne
Copy link

Closing in favor of #67

@DonJayamanne DonJayamanne added feature-request Request for new features or functionality windows and removed info-needed Issue requires more information from poster bug Issue identified by VS Code Team member as probable bug labels Apr 8, 2018
@bbukaty
Copy link

bbukaty commented Apr 8, 2018

@DonJayamanne I don't really understand that other thread... is there a way to get the select interpreter functionality back? I didn't have this problem before so i think an update broke it, i'm pretty confused and a quick explanation of why i might be having this problem would be really helpful

@DonJayamanne DonJayamanne reopened this Apr 8, 2018
@DonJayamanne
Copy link

I'm sorry, I thought you were selecting an interpreter from the last (that belonged to wsl)
Please could you confirm that you are unable to get the list, instead on getting an error when you select something from the list.
Better yet please create a screen recording of the issue (use licecap)

so i think an update broke it, i

We didn't make any changes that would code this issue (only added support for pipenv). You can try to install an older version of the extension to confirm this.

@DonJayamanne
Copy link

DonJayamanne commented Apr 8, 2018

@wolf99

. I have Msys2 installed on the machine and configured such the programs it provides are available on the PATH

How did you do this?
As requested, please send an screen shot when possible.

@bbukaty
Copy link

bbukaty commented Apr 8, 2018

cap

Here's a recording of the issue. I'm going to try what you mentioned of downloading an older version of the plugin.

@DonJayamanne
Copy link

You can download an older version from here:

Once again, remember to disable auto-updates.
screen shot 2018-04-08 at 3 35 54 pm

@bbukaty
Copy link

bbukaty commented Apr 8, 2018

whoah, installing the january version of the extension fixed all the problems I was having.

To clarify, the sources of my frustration were:

The behavior of the default python config seemed different. In the previous version the config was simply labeled "Python". The new version's default was "Python: Current File", with different settings in the JSON.

Running python with the config "Python: Current File" seemed to run the file using the terminal specified in the user settings, which in my case was
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe",
This caused an error, as bash would look for the directory "d:\Desktop\pytest\test.py", but not find it as the WSL filesystem is structured differently. That didn't happen in the previous version with the "Python" config - it would run in the windows command line in spite of the above user setting, allowing me to have bash in the integrated terminal without a hitch.

Additionally, in the new version, running the debugger would switch focus to the Terminal window instead of the Debug Console window, and from there I would need to click on the Debug Console. In the old version focus would go directly to the Debug Console. (This one might be intentional I guess, so if there's a setting for that or something let me know).

Finally of course the ENOENT issue preventing me from switching my python interpreter is not present in the older version.

@bbukaty
Copy link

bbukaty commented Apr 8, 2018

Here is a screengrab of the functionality of the older version:
cap2
The only weird thing about this is that, for some reason, when my selected interpreter is /usr/bin/python2 (in the old version), the test file still runs and prints out "a". Not sure why that happens.

@DonJayamanne
Copy link

DonJayamanne commented Apr 9, 2018

@bbukaty

  • Please could you paste the contents of your PATH environment variable.
  • Do you still have wsl set up (I assume you do, based on the screen shots)
  • Please paste the following into your terminal and let me know what you get python -c "import sys; print(sys.executable)"
  • How do you start vscode? Are you starting it from the bash shell? or just from windows programs menu?
  • Please could you provide your OS, VS Code Version, Python Version

@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster and removed feature-request Request for new features or functionality labels Apr 9, 2018
@DonJayamanne DonJayamanne added this to the April 2018 milestone Apr 9, 2018
@bbukaty
Copy link

bbukaty commented Apr 9, 2018

  • Here's my path:
    PATH=C:\ProgramData\Oracle\Java\javapath; C:\Windows\system32; C:\Windows; C:\Windows\System32\Wbem; C:\Windows\System32\WindowsPowerShell\v1.0\; C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common; C:\Program Files (x86)\QuickTime\QTSystem\; C:\Program Files\Microsoft SQL Server\130\Tools\Binn\; C:\Program Files (x86)\GtkSharp\2.12\bin; C:\Program Files (x86)\Windows Live\Shared; C:\WINDOWS\system32; C:\WINDOWS; C:\WINDOWS\System32\Wbem; C:\WINDOWS\System32\WindowsPowerShell\v1.0\; D:\Programs\broadcom\; D:\Programs\broadcom\syswow64; C:\Program Files\Microsoft SQL Server\110\Tools\Binn\; C:\Program Files\CMake\bin; C:\WINDOWS\system32; C:\WINDOWS; C:\WINDOWS\System32\Wbem; C:\WINDOWS\System32\WindowsPowerShell\v1.0\; C:\Program Files\dotnet\; C:\Program Files\Git\cmd; C:\python35\Scripts\; C:\python35\; C:\Users\Buck\AppData\Local\Microsoft\WindowsApps; C:\msys64\mingw64\bin; C:\msys64\usr\bin; C:\Program Files\Microsoft VS Code\bin

  • I do have wsl set up.

  • pasting that code into normal cmd gives C:\python35\python.exe, pasting it into bash gives /usr/bin/python

  • I start vscode normally from windows by clicking an icon in the start menu.

  • OS: Windows 10 home, version 1709, OS build 16299.309

  • VSCode version:
    Version 1.22.1
    Commit 950b8b0d37a9b7061b6f0d291837ccc4015f5ecd
    Date 2018-04-06T02:26:57.615Z
    Shell 1.7.12
    Renderer 58.0.3029.110
    Node 7.9.0
    Architecture x64

  • Python installations: in wsl I have python 2.7.12 and python 3.5.2 installed. In windows I have python 3.5.3 and 2.7.13 installed.

Let me know if you need any more information!

@wolf99
Copy link
Author

wolf99 commented Apr 9, 2018

Ill be uploading a screenshot soon, however I quickly wanted to mention that the problem I am seeing has little to do with WSL as I am on Windows 7, not Windows 10. Windows 7 does not have WSL (hence the MSYS bash).

@wolf99
Copy link
Author

wolf99 commented Apr 9, 2018

Here are the screen shots. I don't get as far as being presented with a list of interpreters. As soon as I select "Python: Select Interpreter" the menu disappears and the error appears. FYI, I have the path to python set in global preferences "python.pythonPath": "C:\\Python\\Python36-32"

1

2

@wolf99
Copy link
Author

wolf99 commented Apr 9, 2018

To add MSYS2 provided programs to the PATH I just added C:\msys64\usr\bin to my system Path variable IIRC.

@DonJayamanne
Copy link

DonJayamanne commented Apr 9, 2018

@wolf99 @bbukaty @brettcannon
I can replicate this at my end with msys2 setup.

  • Install msys2
  • Install python pacman -S python
  • Add C:\msys64\usr\bin and C:\msys64\mingw64\bin

@DonJayamanne
Copy link

@wolf99 @bbukaty

  • Please uninstall your python extension
  • Download the following development version of the Python extension python-2018.4.0-alpha-dev.vsix
  • Open VS Code and install the above extension using the command Install from VSIX from the Command Palette
  • Restart VS Code once installation has been completed (you'll get a prompt)
  • Test again, it should work

Let me know how this goes

@bbukaty
Copy link

bbukaty commented Apr 10, 2018

Using the alpha version above, when I do Python: Select Interpreter, I get the error: command 'python.setInterpreter' not found
image

@DonJayamanne
Copy link

Please uninstall and reinstall the extension. Finally check the error in the console window.

@bbukaty
Copy link

bbukaty commented Apr 10, 2018

I uninstalled and reinstalled.
When I open vscode, I get this error:
image

and when I do select interpreter, I get the error pictured in my last post, with this output in the console:
image

@DonJayamanne
Copy link

I'm sorry for not testing the build, looks like we're missing a dependency. I'll get this fixed asap and upload a new build of the extension (#1360)

@DonJayamanne
Copy link

@bbukaty
Here's a new version of the extension, please test and let me know how this goes.
https://pvsc.blob.core.windows.net/extension-builds/python-2018.4.0-alpha-dev2.vsix
Thanks

@bbukaty
Copy link

bbukaty commented Apr 11, 2018

Yep, that new version works.
As mentioned above the debugger now runs through the shell specified in the setting terminal.integrated.shell.windows, but I'd like to leave that set to bash, which is now causing issues.
Is there a way to separate which shell the debugger uses from the shell used in the integrated terminal?
Let me know if I should make a separate post or something about this.

Regardless, thanks for the quick fix on this issue.

@DonJayamanne
Copy link

Let me know if I should make a separate post or something about this.

Yes, please do so.

@wolf99
Copy link
Author

wolf99 commented Apr 11, 2018

Haven't tried it yet but thanks for the quick fixes on this @DonJayamanne (and the testing @bbukaty), much appreciated!

@lock lock bot locked as resolved and limited conversation to collaborators Jul 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants