Import "brownie" could not be resolved in Pylance

Error is: Import "brownie" could not be resolvedPylance

I know there are other SO posts that refer to this, but it seems most of them are talking about booting up a new env and installing x package into that virtual env.

However with Brownie, I'm especially confused because the brownie docs say:

pipx installs Brownie into a virtual environment and makes it available directly from the commandline. Once installed, you will never have to activate a virtual environment prior to using Brownie.

I don't want to mess with the virtual env that brownie uses.

Anyways, my code runs fine and the command line tells me that brownie is installed.It's just that this warning is really annoying me. Can anyone tell me how to clear it up? Thanks!


Solution 1:

It's happening because we install python with pipx instead of pip. pylance looks in the location our pip files are generally stored, and doesn't see brownie since we installed with pipx (which installed to it's on isolated virtual environment). So you have a few options:

  1. Ignore it
  2. Install brownie with pip in a virtual environment (not recommended)

If there is another suggestion, happy to hear it