Elliott B
Elliott B

Reputation: 1199

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?

Upvotes: 0

Views: 552

Answers (1)

Brett Cannon
Brett Cannon

Reputation: 15990

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.

Upvotes: 1

Related Questions