microsoft / vscode-python

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

Extension is not using first available python interpreter in PATH #4250

Closed JamesMusicTribe closed 5 years ago

JamesMusicTribe commented 5 years ago

Environment data

Expected behaviour

To run python projects using the current Python in the local environment. No issues with previous version.

Actual behaviour

Tries to run the python with location: "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\python.exe"

Had to amend the python.pythonPath setting to: "C:\Python27\python.exe" for it to continue to work.

Shouldn't this take from the current local environment "PATH" settings?

Steps to reproduce:

  1. Launch python script with default "python" as python path with multiple installations of python on machine, Including Visual Studio Python and standard C:\python27 installation.

Logs

E:\Projects\synths>cd E:\Projects\synths && cmd /C "set "PYTHONPATH=C:\Python27\DLLs;C:\Python27\Lib\lib-tk;E:\Projects;E:\Projects\synths;" && set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\python.exe" c:\Users\james.morrell\.vscode\extensions\ms-python.python-2019.1.0\pythonFiles\ptvsd_launcher.py --default --client --host localhost --port 58007 E:\***************.py "
Traceback (most recent call last):
  File "c:\Users\james.morrell\.vscode\extensions\ms-python.python-2019.1.0\pythonFiles\ptvsd_launcher.py", line 21, in <module>
    import ptvsd
  File "c:\Users\james.morrell\.vscode\extensions\ms-python.python-2019.1.0\pythonFiles\lib\python\ptvsd\__init__.py", line 13, in <module>
    from ._vendored import force_pydevd
  File "c:\Users\james.morrell\.vscode\extensions\ms-python.python-2019.1.0\pythonFiles\lib\python\ptvsd\_vendored\force_pydevd.py", line 20, in <module>
    pydevd_constants = import_module('_pydevd_bundle.pydevd_constants')
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "c:\Users\james.morrell\.vscode\extensions\ms-python.python-2019.1.0\pythonFiles\lib\python\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_constants.py", line 164, in <module>
    from _pydev_imps._pydev_saved_modules import thread
  File "c:\Users\james.morrell\.vscode\extensions\ms-python.python-2019.1.0\pythonFiles\lib\python\ptvsd\_vendored\pydevd\_pydev_imps\_pydev_saved_modules.py", line 8, in <module>
    import socket
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\socket.py", line 49, in <module>
    import _socket
ImportError: DLL load failed: %1 is not a valid Win32 application.

Internal error detected. Please copy the above traceback and report at
https://github.com/Microsoft/vscode-python/issues/new

Press Enter to close. . .

Current Environment PATH:

PATH=
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
C:\Program Files\Microsoft MPI\Bin\;
C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\compiler;
C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;
C:\ProgramData\Oracle\Java\javapath;
C:\Program Files\Git\cmd;
C:\Program Files\TortoiseGit\bin;
C:\cygwin64\bin;
C:\cygwin\opt\cross\x-tools\arm-unknown-linux-gnueabi\bin;
C:\mingw\mysys\1.0\bin;
C:\MinGW\bin;
C:\Ruby200-x64\bin;
C:\Python27\;
C:\Python27\Scripts;
C:\Perl\site\bin;
C:\Perl\bin;
C:\ProgramData\Oracle\Java\javapath;
C:\Program Files\Microsoft\Web Platform Installer\;
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;
C:\Users\james.morrell\.dnx\bin;
C:\Program Files\Microsoft DNX\Dnvm\;
C:\Program Files\dotnet\;
C:\Program Files (x86)\Microsoft VS Code\bin;
C:\Program Files (x86)\STMicroelectronics\st_toolset\asm;
C:\MentorGraphics\9.5PADS\SDD_HOME\common\win32\bin;
C:\MentorGraphics\9.5PADS\SDD_HOME\common\win32\lib;
C:\MentorGraphics\9.5PADS\MGC_HOME.ixn\bin;
C:\MentorGraphics\9.5PADS\MGC_HOME.ixn\lib;
C:\Windows;
C:\Windows\system32;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Program Files\Intel\DMIX;
C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;
c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;
c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;
c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;
C:\Program Files\MicrosoftSQL Server\110\Tools\Binn\;
C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;
C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;
C:\Program Files (x86)\Microsoft VS Code\bin
C:\Program Files (x86)\Microchip\MPLAB C32 Suite\bin;
C:\HashiCorp\Vagrant\bin;
C:\Program Files (x86)\Skype\Phone\;
DonJayamanne commented 5 years ago

No (this change was introduced last release). You need to specify what is to be used. Else it will use the best available interpreter (i.e. latest python version available on your system).