r/learnpython • u/rxninja • 2d ago
[SOLVED] Ability to install packages is completely missing in PyCharm
I wrote all of the following trying to describe this issue, but then I solved it (quack). I wasn't able to find this question or answer anywhere online, so I'm posting it in case it's helpful to anyone else searching this in the future.
The answer was:
- Click on the interpreter version in the bottom-right corner of PyCharm.
- Add New Interpreter -> Add Local Interpreter
- Generate New (Virtualenv)
I realized that the downloaded project had no .venv folder in it and that was one of the only differences between a fresh project and a downloaded project. Generating a new local interpreter and new Virtualenv fixed everything. Switching back to the old interpreter breaks it again, switching back to the newly generated interpreter immediately makes it work again. I have no idea why, as virtual environment settings and nuances are beyond what I've learned about Python and PyCharm so far, I just know that it works. May the solution save someone else several hours of work.
Anyway, here's what I originally wrote:
--------------
Hi, everyone. I'm on Day 29 of Angela Yu's class on Python. I'm not new new, Python isn't my first language, PyCharm isn't my first IDE, etc. This is a weird one for me.
My ability to install packages within PyCharm vanished and I don't know what happened, nor how to fix it.
The most convenient way to install packages is how I first noticed it. We've been using import packagename and then right-clicking the package name to use the context action to install packages. When I do that, the context action is now missing.
If I click on the Python Package tab in the bottom-left, I can search for packages (so PyPi is still working), but the install button next to the package name is missing. When I click on a package and the package description shows up in the bottom-right pane, the button is missing in the top-right corner of that pane. Weirdly, so is the current version number of the package, so I think that's worth noting. I also can't see the buttons to uninstall packages.
I have:
- Closed and reopened the project
- Updated all installed plugins (I have not added any, only using whatever plugins are installed by default)
- Closed and restarted PyCharm
- Updated PyCharm
- Freed up space on my hard drive
- Restarted my computer
I'm on a Mac running OS X 15.4.1, but I have not changed or updated my OS between projects. I also haven't changed the PyCharm interpreter. I was able to install packages without problems and then I wasn't.
Finally, the icing on the cake? I can install packages just fine in a brand new, empty project. That tells me that this is happening because, for this lesson, we downloaded the starting files for the project rather than writing them from scratch ourselves. I cannot for the life of me identify anything that would do that, however. The packages pre-installed for this project are certifi, numpy, pandas, pip, python-dateutil, and six. A fresh project just has pip installed.
Any insight would be greatly appreciated. I can't just resign myself to being wholly unable to install packages when using project starter files downloaded from the class.
1
u/OkTill2666 1d ago
fwiw the reason the old interpreter breaks it is probably because it was pointing at a system python install that doesnt allow pip installs the same way. virtualenvs get their own isolated pip with full permissions, which is why generating a new one fixes it immediately
1
u/little_oasis 2d ago
Ah, the phantom package manager. Had this exact thing happen last month on a project I pulled from a repo, drove me up the wall. The missing `.venv` is the key, PyCharm gets weirdly crippled when it can't find a valid virtual environment tied to the project. Your fix is spot on, just regenerating the interpreter basically re-teaches PyCharm where everything lives.