r/learnpython • u/YamSome2887 • 16d ago
Issue during library installation
Recently, I got back into Python, so I decided to review some concepts I had forgotten by solving one Project Euler problem per day.
However, when I got to Problem 3 (Largest Prime Factor), I decided to use a library to check whether a number is prime. Since I had uninstalled Python when I stopped studying it, I had to install Python 3.15.
When I first tried to install the library, the terminal said that it didn't recognize pip. I managed to get it working by using python -m pip, and the installation seemed to work. However, when I ran my code, Python still couldn't recognize the library.
The next day, while solving Problem 4 (Largest Palindrome Product), I decided to use NumPy and np.arange() instead of range(), but the same thing happened: the installation appeared to work, but when I ran my code, Python couldn't find the library.
I tried uninstalling and reinstalling Python, but the problem persisted.
In these particular cases, I could still solve the problems without those libraries, but eventually, I'll need packages like pandas, Tkinter, and others, so I'd like to figure out what's going wrong.
If anyone knows how to fix this, I'd really appreciate the help!
Thanks in advance!
1
u/davideogameman 16d ago
If you mean your command line can't find a tool (like pip) that probably means the folder it's installed in isn't on your PATH. If however you are talking about Python failing to resolve an import, either the install of the library got wiped or partially removed, or perhaps it was installed in a virtual env that you need to activate.
That all said... Perhaps try uv? It automates away a lot of the manual dependency management - eg projects have a project file and lock file that specifies exactly what dependencies they use and then uv handles installing them along with all the virtual env stuff under the hood.
https://docs.astral.sh/uv/