简体   繁体   中英

Python peek definition works in vscode, but pylint complains about being unable to import

I want to test some python files in a project before installing them. For this I entered the folder to be installed in my vscode workspace settings as follows:

"python.autoComplete.extraPaths": [
    "${workspaceRoot}/lib_python/release"
]

Now I have a test file in my workspace that imports from the above mentioned folder. Suggestions work fine, it also gives me definitions while hovering with the mouse over a class name from the imported file. However, half my code is underlined in red, because pylint says it does not know the definitions and cannot import.

Question: Is there a way to also make whatever part of the python plugin by Don Jayamanne is responsible for the red underlining find the additional import folders?

So what worked for me now is to set additional paths in a .env file in the project's root folder. This file will be read by the python extension of vscode.

Example:

PYTHONPATH=./lib_python/release

In User Settings -> Extensions be sure python command is the right one. On my Mac, python refers to Python 2.x, however python3 refers to Python 3.X. I simply changed VSCode's python command to python3 and this resolved my issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM