Closed LuckyLuc96 closed 1 month ago
I attempted to reproduce your issue and was able to setup a basic python venv with selenium==4.22.0
and zed/pyright worked as expected without complaint.
Can you confirm which version of python/selenium you're running?
For reference here's the Zed Editor Python Docs.
I attempted to reproduce your issue and was able to setup a basic python venv with
selenium==4.22.0
and zed/pyright worked as expected without complaint.Can you confirm which version of python/selenium you're running?
For reference here's the Zed Editor Python Docs.
Hello. I am using selenium 4.22.0 , Python 3.10.12, and zed 0.143.7
I think this may be that I have selenium installed in an environment that perhaps zed does not see or recognize. I honestly don't know enough about environments to explain more, but this one was set up using vscode.
The .venv is in the folder "Python" and the program I am working on is in a folder inside of Python called jobbot.
Pyright needs to find your venv, as mentioned in the Python: Virtual Environment Docs
Having done that, you would create a
pyrightconfig.json
with the following content:{ "venvPath": ".", "venv": ".venv" }
If you prefer to use a pyproject.toml file, you can add the following section:
[tool.pyright] venvPath = "." venv = ".venv"
You can also configure this option directly in your settings.json file (pyrights settings)
{ "lsp": { "pyright": { "settings": { "python": { "pythonPath": ".venv/bin/python" } } } } }
Pyright needs to find your venv, as mentioned in the Python: Virtual Environment Docs
Hello. I spent some time on this and really wanted to reply back closing this issue. But sadly my issue remains, and I'll explain what I have tried to do to fix this.
I gave up and completely uninstalled my virtual environment and started from scratch, using the same path.
My settings.json file for Zed will be posted below this. I have tried different variations for the home path (home/lucky1) == $HOME for my OS or often seen as "~" too, without success. I uninstalled pyright from my primary python and installed it for my .env but oddly pyright still functioned correctly, while still not recognizing the newly set up environment.
When I created the new virtual environment, using the same path, I did make sure to activate it and also test that it was working. I tried making a pyrightconfig.json with the venvpath and venv variables set up the same as below, but removed it, as I do desire an outcome that does not require an additional file from the zed settings.json.
I would also like to state that I have verified the full path.
terminal input:
lucky1@pop-os:~$ ls /home/lucky1/Documents/Games/Programs/Python/.venv/bin/
terminal output:
activate activate.fish nodeenv pip3 pyright pyright-python python python3.10 activate.csh Activate.ps1 pip pip3.10 pyright-langserver pyright-python-langserver python3 wsdump
snippet from zed settings.json
{
"lsp": {
"pyright": {
"settings": {
"python": {
"pythonPath": "home/lucky1/Documents/Games/Programs/Python/.venv/bin/python"
}
}
}
},
"tools.pyright": {
"venvpath": "home/lucky1/Documents/Games/Programs/Python/.venv",
"venv": ".venv"
},
}
Hi! Sorry you're running into trouble, hopefully we can get this sorted.
The tool.pyright
block is not valid in Zed settings. Remove it.
The paths you're specifying should be relative to your project directory of your Zed workspace (Python
in your case). Even when this is in your user zed settings ~/.config/zed/settings.json
you're defining a default project-relative path. So pythonPath should just be .venv/bin/python
instead.
There are three possible methods to configure pyright (pyproject.toml, pyrightconfig.json, lsp block in zed settings) -- you only need one. Since you're using a venv at .venv
inside your project dir (Python/
from your screenshots) you can pick any of the examples from the docs and create those files next to your .venv
folder inside Python
:
See: https://zed.dev/docs/languages/python#virtual-environments
Hi! Sorry you're running into trouble, hopefully we can get this sorted.
Changing the path of my python from the full path to the relative path was the answer! Thank you so much for the help here.
Check for existing issues
Describe the bug / provide steps to reproduce it
With this specific import, Pyright is highlighting this import as an error, when it is not one.
Any related imports related to webdriver are flagged by Pyright with "Pyright: Import "selenium.webdriver.common.by" could not be resolved"
Apologies if this is the wrong place to post this.
Environment
Zed version 0.143.6![image](https://github.com/user-attachments/assets/92938c13-79da-462a-9113-c3e0009f2fc0)
If applicable, add mockups / screenshots to help explain present your vision of the feature
Happy solution would look like:![Screenshot from 2024-07-12 00-19-28-after](https://github.com/user-attachments/assets/0df3780a-5a65-478d-a96d-13770c6026ae)
If applicable, attach your Zed.log file to this issue.
Zed.log