-
Notifications
You must be signed in to change notification settings - Fork 93
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
Python: InvalidPythonEnvironment on interpreter startup #2120
Comments
Seeing a different error printed out to the Console on startup:
The interpreter failed, but once I started up a new one, all was fine. EDIT: this one was due to an error in my file, disregard. But it is worth it to note that terminal errors populate like this? I'm not sure if they should be suppressed, but I definitely thought it was related to the python-extension files since this is the only place I've seen it populate. |
Also in Output > Python Language Server, I'm seeing the following:
and in Output > Window
|
This error occurs in any LSP subprocess that requires pickling, eg going to definition or viewing document symbols.
|
I briefly looked into this before I went OOO. Here are some findings which may be helpful. This issue is related to the upstream issue: microsoft/vscode-python#22659. I originally noticed that microsoft/vscode-python#22466 introduced the issue, so I reverted it in https://github.com/posit-dev/positron-python/pull/300. But it looks like a better fix was made upstream in microsoft/vscode-python#22713. So maybe as a starting point we should revert my revert PR 300 and then cherry-pick the upstream PR 22713? IIUC there is also an issue in Jedi's subprocess script which is expected to write a value to stdout that can be unpickled, but it's currently crashing. I think this is due to the way our vendoring rewrites imports, clashing with how the above script works. It's not pretty at all, but I think we can fix it by updating our to: def _get_paths():
# Get the path to positron, in which jedi and parso are vendored.
_d = os.path.dirname
return {"positron": _d(_d(_d(_d(_d(_d(_d(__file__)))))))} I don't yet fully understand why this script needs to hack with the import machinery, but I think patching it as above will make it function as it should given the rewritten vendored imports. For reference, the way I added to patch files was to first stage the current version of the file Hope this helps. |
Ah, nice! This is super helpful context. I narrowed down the impact of this error to the Positron LSP features that use jedi's I can narrow down the issue to working at b7d17a and broken at 9ec300, so I'll start with cherry picking the upstream PR! |
After merge of https://github.com/posit-dev/positron-python/pull/342 I can no longer reproduce the original InvalidPythonEnvironment error. We ran into a new error, where certain LSP actions in certain Python interpreters would result in the following error message We tracked this down to incorrectly typing import names as Next step is to check if patching this: https://github.com/davidhalter/parso/blob/master/parso/cache.py#L52-L57 |
In dev Positron as of today, I can start up a Python interpreter and I see:
|
… for vendored `parso` Merge pull request #358 from posit-dev/fix-parso-cache use unique cache directories for vendored `parso` -------------------- Commit message for posit-dev/positron-python@cfdcbb6: use unique cache directories for vendored `parso` Addresses #2120. Authored-by: Wasim Lorgat <mwlorgat@gmail.com> Signed-off-by: Wasim Lorgat <mwlorgat@gmail.com>
… for vendored `parso` Merge pull request #358 from posit-dev/fix-parso-cache use unique cache directories for vendored `parso` -------------------- Commit message for posit-dev/positron-python@cfdcbb6: use unique cache directories for vendored `parso` Addresses #2120. Authored-by: Wasim Lorgat <mwlorgat@gmail.com> Signed-off-by: Wasim Lorgat <mwlorgat@gmail.com>
Positron Version:
Positron dev
Steps to reproduce the issue:
I don't notice any effects from this error from a quick check, but it seems to occur on startup for me, but this seems related to recent vendoring.
The text was updated successfully, but these errors were encountered: