Python virtualenvs/Poetry #16533
Replies: 4 comments 3 replies
-
This is not a direct answer, but, when adding pyright configuration, you should use |
Beta Was this translation helpful? Give feedback.
-
I do not use poetry so this is not really an answer in that context and I agree 100% that it would be great to make Zed’s detection of python virtual environments more comprehensive, hands-off, and bullet-proof. In the mean time, what I’ve done is configure things in my setup (where I use pyenv and direnv to create python projects) so that my virtual environment python install (regardless of what python version a given venv is using) will always be located under And then I have the following in my zed
In this way, these python LSP’s find the venv in every project without requiring a |
Beta Was this translation helpful? Give feedback.
-
https://www.reddit.com/r/ZedEditor/comments/1cth023/cant_get_zed_to_recognize_any_python_libraries/ It seems this approach can solve the current problem, but Zed is still not smart enough. |
Beta Was this translation helpful? Give feedback.
-
In pyproject.toml: [tool.pyright]
venvPath = "."
venv = ".venv" pyright will look for the virtual environment in the project. Next, we need to configure poetry to create the virtual environment in the project: poetry config virtualenvs.in-project true |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have started to use Zed and I am finding an ergonomics problem with Python (Poetrry/virtualenvs).
When I have a project, Zed doesn't automatically find the virtual env / poetry install for the project. Which means that the editor is not able to resolve dependencies for packages used in the project.
I have found a couple of answers here, but they require adding a configuration file for pyright - which is very ugly compared to all other editors...
... It so happens that other editors don't require that (and adding a configuration file for a pyright environment would cause problems for other collaborators).
For example with vim I do:
poetry shell vim blah.py # all fine here
Because vim is run inside the virtual environment the problem is automatically solved. The impression that I have is that other editors are able to solved this problem in whatever way.
Any ideas on how to solve this elegantly (i.e. this is automaticallly solved without adding pyright configuration directives)?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions