Reputation: 1021
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!
Upvotes: 5
Views: 2897
Reputation: 11
The suggested methods seem correct, however, all of them are for Linux/OS, making the answer really confusing for the windows users.
I followed Patrick's tutorial and my path is: C:\Users\korisnik.local\pipx\venvs\eth-brownie\Scripts ^Korisnik Being the name of the account. It's honestly hard to find path if you don't know where to look at.
Upvotes: 1
Reputation: 21
The answer is probably quiet simple, as for me, each time I have to use different packages, I need to select the right interpreter in order not to get that silly warning.
If you are on Windows (I assume you are using VS code) follow the following steps:
Otherwise, if you are on an Apple device, the Steps to follow should be pretty much the same but at point 4) you need to enter a path that looks similar to the following: ~/.local/pipx/venvs/eth-brownie/bin/python
.
So far, this method allowed me to solve any "Import" could not be resolved in Pylance.
Upvotes: 1
Reputation: 494
I tried below pip command & the warning in my python code got resolved.
pip install brownie
Upvotes: 1
Reputation: 41
for Windows:
This is an addition to @Ali Sıtkı Aslantaş's answer
Upvotes: 4
Reputation: 109
Upvotes: 10
Reputation: 6131
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:
pip
in a virtual environment (not recommended)If there is another suggestion, happy to hear it
Upvotes: 7