Closed suiyuanla closed 1 year ago
I think it maybe useful if I can run comand "conda activate pytorch" before the"pyright-langserver --stdio" .But I try "cmd_windows":["conda activate pytorch","pyright-langserver","--stdio"], it doesn't work
hi, @Adesince .
what if you try "cmd_windows": ["pyright-langserver.exe", "-v" , "G:/anaconda3/envs/pytorch", "--stdio"],
I try it and I create a file name "pyrightconfig.json" according the pright dom, But it still doesn't work. I'm sure the path is right, because I can run this code.
Where is you CudaText project file saved?
I make a test project and the cudatext project file in:
And my anaconda env path is I don't know why it doesn't work :(
in CudaText console you have line like this: LSP: starting server - Python; root: E:\....
right?
this root folder is the folder of .cuda-proj
file
i think this root folder is important to pyright-langserver (like to any other lsp server)
in cuda_lsp config you have this setting:
"root_dir_source": [ 0, 1, 2 ],
* root_dir_source - LSP server root directory source (accepts list of values for fallback):
* 0 - parent directory of '.cuda-proj'
* 1 - first directory in project
* 2 - project main-file's directory
i think, to let pyright-langserver to read pyrightconfig.json
, it must be located in root dir.
try to save your .cuda-proj to dir where pyrightconfig.json
is located, and reopen it from there.
this worked for me in pyrightconfig.json:
{
"stubPath": "G:/anaconda3/envs/pytorch/lib/site-packages"
}
.cuda-proj
to dir where pyrightconfig.json
is locatedstubPath
in pyrightconfig.json
I save the .cuda-proj in the project dir, it still doesn't work. Then I try to add the "stubPath" as you sat , amazingly It worked. I think I should read the pyright document carefully, I even don't konw the option "stubPath" . It works, thank you very much.😊😊
answer about stubPath
was found here: https://github.com/emacs-lsp/lsp-pyright/issues/7
i don't know if this is correct approach, but it works.
also check lsp log in bottom panel. maybe python version is wrong still.
3.8 is global 3.10 in anaconda env
i see it assumes 3.8:
It seems that the python 3.8 is cudatext's python environment. Because my global python version is 3.9.13, and my conda env version is 3.9.16. So I don,t know why lsp_server can't use the virtual python environment
But I set the project python version is "3.9.16" in pyrightconfig.json, and the python path to excute the python script also is my conda env, so I think it isn't a problem maybe.
This plugin helps me to write python scripts,thanks. But I meet some problem about config lsp_pyright.I use the anaconda virtual env in anaconda3/envs/pytorch/python.exe for my project, but the pyright can't use this env .Such as "import torch",I can run this ,but pyright say it can't find this moudle. and follow is my lsp_pyright.json I'm a rookie in programing and my english is poor.Excuse me