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

Python / Poetry / Pyright cannot import modules (ModuleNotFoundError) #20455

Open
1 task done
tsoernes opened this issue Nov 9, 2024 · 0 comments
Open
1 task done
Labels
bug [core label] language server An umbrella label for all language servers language An umbrella label for all programming languages syntax behaviors python Python programming language support

Comments

@tsoernes
Copy link

tsoernes commented Nov 9, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

I have a Python project with a virtual environment created with poetry. It's using the pyright LSP if that matters. The REPL is unable to import modules that are installed in the virtual environment.

$ ls -Ah                                                                                                                  (base) 14:10:50
.git/  poetry.lock  pyproject.toml  pyrightconfig.json  setfit_lime.py  .venv/
$ cat pyrightconfig.json                                                                                                  (base) 14:09:49
{
  "venvPath": ".",
  "venv": ".venv",
  "python.pythonPath": "./.venv/bin/python"
}
$ jupyter kernelspec list                                                                                                 (base) 14:09:51
Available kernels:
  python3    /home/torstein/code/nve/.venv/share/jupyter/kernels/python3
  myenv      /home/torstein/.local/share/jupyter/kernels/myenv
  nve-env    /home/torstein/.local/share/jupyter/kernels/nve-env
$ poetry run python -c "import datasets"                                                                                  (base) 14:14:42
$ # succeeds

image

Note that the kernels listed in jupyter kernelspec list is not listed in zed. I have tried restarting zed and doing repl: refresh kernel..

The kernel appears in REPL sessions
image
But I cannot select it. I do not want to edit a global config file since the kernel will vary for each project. Each poetry project has its own poetry kernel and virtual environment.

Environment

Zed: v0.160.7 (Zed)
OS: Linux Wayland fedora 41
Memory: 30.9 GiB
Architecture: x86_64
GPU: Intel(R) Graphics (RPL-U) || Intel open-source Mesa driver || Mesa 24.2.6

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log
Zed: v0.160.7 (Zed)
OS: Linux Wayland fedora 41
Memory: 30.9 GiB
Architecture: x86_64
GPU: Intel(R) Graphics (RPL-U) || Intel open-source Mesa driver || Mesa 24.2.6
@tsoernes tsoernes added admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue labels Nov 9, 2024
@JosephTLyons JosephTLyons added python Python programming language support language An umbrella label for all programming languages syntax behaviors language server An umbrella label for all language servers and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] language server An umbrella label for all language servers language An umbrella label for all programming languages syntax behaviors python Python programming language support
Projects
None yet
Development

No branches or pull requests

2 participants