Problem in using libraries

Mats Wichmann mats at wichmann.us
Tue Apr 4 17:27:50 EDT 2023


On 4/3/23 10:43, Pranav Bhardwaj wrote:
> Why can't I able to use python libraries such as numpy, nudenet, playsound,
> pandas, etc in my python 3.11.2. It always through the error "import
> 'numpy' or any other libraries could not be resolved".

Will restate what others have said in the hopes it might be even more 
clear that way.

Python has an internal search path that it uses to find the module when 
you ask to "import".  If a module is not found, that means it's not in 
the search path ("it's always a path problem"). You installed it, sure - 
but it went somewhere else.

The search path is installation-specific (not just version-specific: for 
example if you have a system install of 3.10.x, and a virtualenv using 
the same 3.10.x, those will have different search paths). The search 
path can be amended or changed, but that's a different story.

If you're going to install with pip, use the same Python you're going to 
do your work with. Don't trust that a command named "pip" maps to the 
same installation as that Python command. For that, either use an 
activated virtualenv, or do "name-of-my-python -m pip install".  You can 
always check your work by doing "name-of-my-python -m pip list" - what 
does that particular installation see as installed?

Or - if you're using the classic set of "scientific" packages like numpy 
and pandas, you might look at installing it all using conda instead of 
pip: it to a large extent exists to help with getting those very common 
bundles of things set up without going through the wrestling match 
you're going though.


More information about the Python-list mailing list