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

Use rope from non-virtualenv #901

Open
agentx3 opened this issue Mar 13, 2023 · 4 comments
Open

Use rope from non-virtualenv #901

agentx3 opened this issue Mar 13, 2023 · 4 comments
Assignees

Comments

@agentx3
Copy link

agentx3 commented Mar 13, 2023

What's the output of :CocCommand pyright.version
[coc.nvim] coc-pyright 1.1.296 with Pyright 1.1.298


What's the output of :CocCommand workspace.showOutput Pyright
Workspace: /home/agentx3/projects/sandbox/python
Using python from /home/agentx3/projects/sandbox/python/venv/bin/python

[Info - 00:35:15.606] Pyright language server 1.1.298 starting
[Info - 00:35:15.607] Server root directory: /nix/store/qknanwbd9qgmal10myk8ixg7aagdnbd8-vimplugin-coc-pyright-1.1.296/node_modules/pyright/dist/
[Info - 00:35:15.609] Starting service instance "python"
[Info - 00:35:15.616] Starting service instance ""
[Info - 00:35:15.620] No configuration file found.
[Info - 00:35:15.620] No pyproject.toml file found.
[Info - 00:35:15.620] Setting pythonPath for service "python": "/home/agentx3/projects/sandbox/python/venv/bin/python"
[Warn - 00:35:15.624] stubPath /home/agentx3/projects/sandbox/python/typings is not a valid directory.
[Info - 00:35:15.644] Assuming Python version 3.10
[Info - 00:35:15.644] Assuming Python platform Linux
[Info - 00:35:15.703] Searching for source files
[Info - 00:35:15.704] Auto-excluding /home/agentx3/projects/sandbox/python/venv
[Info - 00:35:15.705] Found 1 source file
[Info - 00:35:15.706] No pyproject.toml file found.
[Info - 00:35:15.706] Setting pythonPath for service "": "/home/agentx3/projects/sandbox/python/venv/bin/python"
[Warn - 00:35:15.706] stubPath typings is not a valid directory.
[Info - 00:35:15.730] Assuming Python version 3.10
[Info - 00:35:15.730] Assuming Python platform Linux
[Info - 00:35:15.759] Searching for source files
[Info - 00:35:15.759] No source files found.


Short: Pyright tries to import rope from the virtualenv instead of the system python or the nvim python provider. It should either 1) look in those places instead or 2) look in those places in addition to the virtualenv.

Context: If rope is not installed inside the virtualenv when trying to use the code actions for auto-imports, I get the ModuleError Rope not installed error.

Extraneous Info:I noticed for certain packages nvim can pull from multiple places. Ex: black is called by the python provider in g:python3_host_prog while mypy/pylint are called with the python packages available to the system python !python. I found this out by installing rope in different places until it worked. Might be related to #344 (comment) It would be nice to not have to install rope inside every virtualenv that I would like to use rope in. Also maybe worth noting that the virtualenv is getting activated once inside nvim regardless of whether or not the virtualenv was activated within the shell first.

Many thanks

EDIT: More info:
Results of running :python import rope in nvim

Directory has venv? rope on system? rope in venv? python import rope success
N/A
N/A
@agentx3
Copy link
Author

agentx3 commented Mar 13, 2023

I looked into it more and maybe these changes would be relevant?
agentx3@3f7f723

@fannheyward
Copy link
Owner

Thank you for your report, will look into this next week cause I'm busy right now with my personal things.

@fannheyward
Copy link
Owner

fannheyward commented Apr 20, 2023

Sorry for the delay.

coc-pyright uses the detected Python, here is /home/agentx3/projects/sandbox/python/venv/bin/python to run refactor.py that import rope, this means rope is needed to install into/with this Python.

Will find a better way for this case, for now you need to install rope in venv.

@fannheyward
Copy link
Owner

when trying to use the code actions for auto-imports, I get the ModuleError Rope not installed error.

The new import codeAction won't depend on Rope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants