Python imports not resolved in forked module

I’m using a Python virtual env and I’ve installed a bunch of modules there. My code (which I just started working on and isn’t even in source control yet) wasn’t finding those modules, but I fixed this by creating a pyrightconfig.json that points to the virtual env.

Now I forked another module from Github and put it under the same parent directory as my own code. It is not finding its dependencies in the virtual env lib directory, even if I use exactly the same pyrightconfig.json.

I have two theories:

  1. Maybe the problem is somehow related to the fact that the forked module is in GitHub? I have no idea why this would be but it’s the only really difference between it and my own code.
  2. Or maybe the forked module is specifying its library path in some other way? But I can’t find anywhere plausible where it might be doing that.

This isn’t preventing me from working since the code runs fine, but it is annoying the Cursor is telling me “Import XYZ not resolved” for a bunch of dependencies, and this could mask real errors.

Anyone have any idea what is going on or what line of investigation I could use to find the root cause?

I think I figured this out. I added the path to the virtual environment site-packages directory to the Pylance settings for my workspace, and it seems to work fine now.

1 Like