简体   繁体   中英

PyLint is showing import-error for package installed in venv

Using VS Code on a Mac, I am getting a linting error that it can't find a package. I copied the package to lib/python-edl-master and I added it to the path in workspace settings like this:

"terminal.integrated.env.osx": {
    "PYTHONPATH": "lib/python-edl-master" }

So the code runs fine, but I would like to avoid this linting error. I also installed some other packages using pip in the venv at env/lib/python-3.8/site-packages and those are not showing any error. The reason I chose to install this one separately is that I will be modifying it, so I want the code to be tracked in git. Do I have to add the path separately to pylint somehow?

The change above only applies to the terminal itself, not to the tools run by the extension itself. For that you will want to create a .env file and add your PYTHONPATH setting:

PYTHONPATH = lib/python-edl-master

By the way, the common practice for vendoring projects into your source code is via a subpackage in your project called _vendor . That way it sits within your code and becomes less of a special case.

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