-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Wrong python interpreter selected in multiroot workspaces when debugging using ${command:python.interpreterPath} #18482
Comments
Hi @gracicot, thank you for reaching out. You shouldn't have to specify the What happens if you remove the |
@kimadeline Seems like it's working without the |
After digging deeper in the code, we do support vscode-python/src/client/debugger/extension/configuration/launch.json/interpreterPathCommand.ts Lines 30 to 42 in 33476c4
This assumption is incorrect, since this argument isn't there. This will result in us trying to get the first Python path we can get our hands on (because of the tl;dr: It's a bug on our end, thank you for reporting it! |
* Fixed namespace and type errors * Fetch Jupyter Notebook Interpreters if there are multiple available and fetches the path of the interpreter. * Complying types to reduce errors * Ran prettier * News * Used prettier on service.ts * Requirements.txt for Python Action Checking * Removed pr file check * News * News * Updated cffi version * Ran prettier --check 'src/client/**/*.ts' 'build/**/*.js' for Formatting Multiple Files * Fixed client factory error and installed react to fix eslint errors. * Ran global prettier * Removed unused imports causing errors * Updated ciffi * Mass prettier linting * Removed check python formatting - it was causing errors * Linting back * Removed .eslintignore to fix eslint errors - can be generated again * Added eslint back * Reverted back to original changes before my commits. * Updated news * Error message if you try to run code with no active text editor opened. * News * Used IApplicationShell * Removed unnecessary import * Used vscode.window to stop errors. * Testing * Return error * Used IApplicationShell for pop up windows. Fixed spelling mistake * Revered back to vscode while fixing error * Use IApplicationShell for Error Messages * Fixed promise types * Return Error * Created new constant for message * Return a message value * Return the error window * Using active editor to remove errors while resolving errors. * Use appshell for errors * Use an Interface for running the error messages * Changed types * Imported window from vscode * Use IAppShell to display message for testing * Fixed old python that fail to lint * Used linting of interpreterInfo to remove error * Full Stop * Formatted python Files * Linted Files * Linting * Revert * Revert * Python Files reformatted * Used an Interface in a type file * Use IAppShell for testing * Gitignore gitpod for gitpod users * Reverted * Incorporate Testing * Updated prospector * Test * Revert * Revert * Localised Testing * Upgrade vsce * Revert package and package-lock.json * Remove window import * Create a window variable * Remove any types * Import window from vscode * Remove unused imports * Return Types * Fixed testing * Await a call - not the function * Attempt to fix #18455 * New line at the end of the package-lock.json * New line for package.json * Window message to check if Isort has been Downloaded * Window message * Scrapped idea of a window pop up * Revert * Revert * If no text pointer is found * Changed type * Revert * Testing * Ran prettier * Revert * Revert * Remove --live-stream from conda run * Update news * Remove unused commands * Add an Extract Method Command #18518 * Fixed linting * Reverting * Revert --live-stream to just fix one issue * Support multiple line input and indented text * Updated the package-lock.json by updating dependencies.. * Use let instead of var * Updated test.ts to pass checks -> fix ```Import may be converted to a default import``` error * Revert package and package-lock.json * Fix lint errors * Revert * Select the correct python path if no workspace path is available #18482 * Remove old news * More testing and return an empty string if no python path is available.. * New tests * Removed unused dependencies as stated in #16840 * Revert * Removed unused dependencies with depcheck * Brung back the loaders in order to load tests and webpack * Installed more for tests * Installed webpack-cli * Uninstalled webpack so only webpack-cli is installed * Update package-lock.json * Removed more dependecies * Install rxjs-compat * Revert * Cleanup * Installed webpack * Revert * Revert * Removed gulp-rename, sourcemaps, gunzip, chmod and unicode * Reinstated gulp * Brang back unicode * Update package-lock.json * Remove the vscode-debugadapter and the vscode-debugadapter-testsupport * Removed vscode telemetries. * Revert before Merge * Revert * Merge * Made changes as requested * Updated ts-check * Revert Select the Correct Python Path if no workspace path is available. * Revert * Update workspaceFolderUri type after reverting PR * Revert vscode packages in use * Merged Changes and Added Back untildify * Revert * Revert to PR * Update package-lock.json * Added unicode * Added unicode * Revert * Removed the Unused Dependecies, Typescript Char and Typescript Formatter from the Package and Package-lock.json * Update news * Update news entry Co-authored-by: Kim-Adeline Miguel <kimiguel@microsoft.com>
@kimadeline I've been facing this really hard recently. A multi-root workspace keeps using an interpreter defined for the first folder instead of the correct one. Bounty opportunity: I'm ready to pay €20 for this to be fixed. |
I'm not on the Python team anymore, but I'll let them know that it's an acute pain point for you 🙂 |
@lig https://github.com/microsoft/vscode-python/suites/15205238033/artifacts/868956057 fixes the issue described in #18482 (comment), try installing it using |
@karrtikr No effect, sorry. I needed to install code-insiders and I've checked that Python v2023.15.5895828483-dev extension is installed. It looks like it uses a venv defined in the first folder for anything unconditionally now ignoring any folder specific interpreter configuration. |
I see, the cause stated in #18482 (comment) should be fixed, it's likely that there's another bug in addition to that. As a workaround try removing "python": "${command:python.interpreterPath}", in your |
I have only one |
So, now it always uses the first folder's venv for everything except stdlib packages. Using "go to definition" on stdlib packages results in opening a file from system default interpreters' library. I think I can share my entire workspace with you as it contains only Open Source projects at the moment. |
Or maybe some logs would be enough? |
This issue is related to Btw note you need to create separate Each |
I believe the original issue #18482 (comment) should be fixed with #21835, hence I'm closing this. If it isn't please let us know and we'll be happy to have a look again. |
Issue Type: Bug
Behaviour
Expected vs. Actual
Expected:
import
statements works.Actual:
import
statements for packages installed inside the venv don't work.Steps to reproduce:
Create a workspace with the following files:
Here's the content of each files:
python-bug.code-workspace
:project1/project1.py
:project2/.vscode/launch.json
:project2/project2.py
:project2/requirements.txt
:python3 -m venv venv
in the project2 terminalsource ./venv/bin/activate
in the project2 terminalpip install -r requirements.txt
venv
folderpython project2.py
in the project2 console, it should run fineWorkaround
Setting the python interpreter to
${workspaceFolder}/venv/bin/python
inlaunch.json
solves the problem, so it seem that the python plugin select the wrong interpreter.Diagnostic data
python.languageServer
setting: PylanceUser Settings
Extension version: 2022.0.1814523869
VS Code version: Code 1.64.0 (5554b12acf27056905806867f251c859323ff7e9, 2022-02-03T04:20:17.224Z)
OS version: Darwin x64 20.6.0
Restricted Mode: No
System Info
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
A/B Experiments
The text was updated successfully, but these errors were encountered: