Virtualenv won't import packages

While in a virtualenv my scripts won’t import modules unless they are installed globally. I’ve tried uninstalling them and reinstalling them and running my powershell as admin, but this did not solve that problem.

I appreciate the help.

So, I was fiddling around and I somehow resolved this. I believe it may have been becuase I did not set

$env:PYTHONPATH = "$env:PYTHONPATH;."

Sorry for all the trouble.

Try setting the PYTHONPATH to just .

1 Like

I had a package installed on my computer called pylint that was throwing the error for the import problem. Not in the terminal just in Visual Studio Code. So when I actually went and tested the command everything worked fine.

Note to self: Don’t willy-nilly install packages. because it will cause Visual Studio Code to lie to you. Additionally, actually test things instead of relying on “linting” too much. Dumb mistake on my part.

I finally figured out why I was getting error messages with pylint in Visual Studio Code.

The short version is you have to tell vs code which python interpreter to use. By modifying the python settings in the editor to point to your .venvs folder. Then, Ctrl + p and select Python: Select Interpreter which will list your virtual environments.

Hmmmmmmm ok I’ll have to make sure that’s part of my solutions. Thanks for the info.