Mailing List Archive

Problem in using libraries
Why can't I able to use python libraries such as numpy, nudenet, playsound,
in python 3.11.2
--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem in using libraries [ In reply to ]
> On 3 Apr 2023, at 17:46, Pranav Bhardwaj <pranavbhardwaj773@gmail.com> 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".

You need to provide enough details for people to help you.

Include which OS you are using.
Where you got python from.
How you installed the libraries you are trying to use.
Commands and error messages you are seeing.

Barry


> --
> https://mail.python.org/mailman/listinfo/python-list
>

--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem in using libraries [ In reply to ]
On 4/3/2023 12:43 PM, 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".

You need to realize that no one can help you without some specific
information. You have not told us anything. You might as well have
said, if your car didn't start, "My car won't run. Why can't I start it?.

Let's start with the most obvious thing - are those libraries installed?
If not, install them. If you think they have been installed, then
tell us how you installed them and how you know they have been
successfully installed *for the version of python* you are trying to use.

Let's take numpy. The standard way to install it is using pip. You have
to make sure that you run the pip program that goes with the version of
Python you plan to use. I'm going to assume that if you type "py"
(without quotes), you will get that version. If not, use the command
you have been using to run Python 3.11.

On my system:

C:\Users\tom>py -V
Python 3.10.9

C:\Users\tom>py -m pip show numpy
Name: numpy
Version: 1.23.4
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email:
License: BSD
Location:
c:\users\tom\appdata\local\programs\python\python310\lib\site-packages
Requires:
Required-by: bokeh, causal-curve, cftime, contourpy, csaps, dcor, emd,
frechetdist, imageio, localreg, matplotlib, mizani, netCDF4, numba,
pandas, patsy, plotnine, pwlf, pyDOE, pygam, PyWavelets, scaleogram,
scikit-image, scikit-learn, scipy, seaborn, sparse, statsforecast,
statsmodels, tifffile

If a library is not installed (I'll use a non-existent library name) -

C:\Users\tom>py -m pip show numpyx
WARNING: Package(s) not found: numpyx

To install numpy with pip *for that version of Python* -

py -m pip install numpy (or a form you may see sometimes: py -m
install --user numpy)

Please reply with this information.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem in using libraries [ In reply to ]
Pranav Bhardwaj wrote at 2023-4-3 22:13 +0530:
>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".

The "libraries" you speak of are extensions (i.e. not part of
the Python download).

Extensions are Python minor version specific.
You must install them for each Python minor version.
E.g. you can use an extension installation for Python 3.10 for
any Python 3.10.x,
but you must install it again for Python 3.11.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem in using libraries [ In reply to ]
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.
--
https://mail.python.org/mailman/listinfo/python-list