PyCharm stopped recognizing installed packages in venv?

This morning, I opened up two venv projects I've been working on for a year+. The first loaded normally, while the second seems to have lost its ability to find any of the packages that are still in the lib/python/site-packages directory that they always have been. I have not modified the parent or any subdirectories nor changed anything about the project since Friday, when I last opened it. Further, when I try to reinstall from a requirements.txt in the directory, it gives me an error that says "Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at [dir]" where dir is the same interpreter I've been using all along. Any ideas on what happened and what I can do?

4
2 comments

Have you tried File | Invalidate Caches / Restart | Invalidate and Restart?

If it doesn't help, compare the Interpreter Paths of the two interpreters and see if there are any differences. https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-reloading-interpreter-paths.html

1
Avatar
Permanently deleted user

I tried Invalidate and Restart first which did not seem to change anything. Then I tried reloading the interpreter path with also didn't work.

I dug a bit deeper and found that something may be up with my pip. I downloaded and re-installed pip using

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py --force-reinstall

When that finished, my package list was still empty in the PyCharm interperter settings interface. I tried reinstalling a package from there, but it gave me a permissions error -- which has never happened before, but I suspect is probably owed to macOS Catalina. So I went to the terminal and installed a package via pip, e.g.

pip install matplotlib

which did not give me any errors. I went to look at the lib/site-packages directory to see why it still wasn't recognizing previously installed packages, it had changed from python3.7 to python3.8. I'm not sure why that would have been the case since I hadn't changed anything from Friday to Monday. In any case, I also tried to install a package through the PyCharm interface, which didn't give me any permissions errors. So my project is back up and running, but not entirely sure what happened exactly.

0

Please sign in to leave a comment.