pypa / packaging-problems

An issue tracker for the problems in packaging
147 stars 34 forks source link

Installation issue #806

Closed ar1964 closed 1 week ago

ar1964 commented 1 week ago

Problem description

Hello all, I'm bignner, recently installed matplotbit on my windows 11 by using pip command (it shows successful), using sublime text3, I tried to write my first code following python crash course book as follows:

import matplotlib.pyplot as plt

squares = [1, 4, 9, 16, 25]
plt.plot(squares)

plt.show()

It seams that I have made some installation mistake, therefore I get following error message:

Traceback (most recent call last):
  File "C:\Users\arabu\AppData\Local\Programs\Python\Python312\Lib\site-packages\numpy\_core\__init__.py", line 23, in <module>
    from . import multiarray
  File "C:\Users\arabu\AppData\Local\Programs\Python\Python312\Lib\site-packages\numpy\_core\multiarray.py", line 10, in <module>
    from . import overrides
  File "C:\Users\arabu\AppData\Local\Programs\Python\Python312\Lib\site-packages\numpy\_core\overrides.py", line 8, in <module>
    from numpy._core._multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\arabu\AppData\Local\Programs\Python\Python312\Lib\site-packages\numpy\__init__.py", line 128, in <module>
    from numpy.__config__ import show as show_config
  File "C:\Users\arabu\AppData\Local\Programs\Python\Python312\Lib\site-packages\numpy\__config__.py", line 4, in <module>
    from numpy._core._multiarray_umath import (
  File "C:\Users\arabu\AppData\Local\Programs\Python\Python312\Lib\site-packages\numpy\_core\__init__.py", line 49, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.12 from "C:\Users\arabu\AppData\Local\Programs\Python\Python312\python.exe"
  * The NumPy version is: "2.1.1"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\arabu\OneDrive\Desktop\python\python_work\sys.py", line 1, in <module>
    import matplotlib.pyplot as plt
  File "C:\Users\arabu\AppData\Local\Programs\Python\Python312\Lib\site-packages\matplotlib\__init__.py", line 159, in <module>
    from . import _api, _version, cbook, _docstring, rcsetup
  File "C:\Users\arabu\AppData\Local\Programs\Python\Python312\Lib\site-packages\matplotlib\cbook.py", line 24, in <module>
    import numpy as np
  File "C:\Users\arabu\AppData\Local\Programs\Python\Python312\Lib\site-packages\numpy\__init__.py", line 133, in <module>
    raise ImportError(msg) from e
ImportError: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
[Finished in 1.2s]

I would really appreciate if you could guide me how to overcome this issue. thank you.

henryiii commented 1 week ago

Simple quick thought: Scripts probably should not be named sys.py. You don't want to risk it overriding import sys, which is integral to how Python works. There are cases where it's fine (like if it's in a module folder), but at the top level, it's a bit scary. I don't think it's this problem (especially if you are running it directly with python sys.py, as it gets loaded as __main__), but just probably good practice.

Is it possible you've mixed a normal Windows install with a WSL install? Everything above looks like normal Windows to me, but just in case. How did you install Python? I'm assuming this is an Intel-based machine, not one of the ARM ones? Did it install quickly (under 10 seconds or so)? It should not have been trying to build numpy.

The file it is failing to find (numpy/_core/_multiarray_umath.cp312-win_amd64.pyd) is clearly present in the wheel: https://inspector.pypi.io/project/numpy/2.1.1/packages/b7/98/5640a09daa3abf0caeaefa6e7bf0d10c0aa28a77c84e507d6a716e0e23df/numpy-2.1.1-cp312-cp312-win_amd64.whl - pip should have just unzipped this into site-packages.

What's actually in C:\Users\arabu\AppData\Local\Programs\Python\Python312\Lib\site-packages\numpy\_core? Does it have _multiarray_umath.cp312-win_amd64.pyd?

(I've edited your question with triple-tick-marks to get it to format properly)

ar1964 commented 1 week ago

Hi henry, Thank you for responding, thing are bit confusing for me due to being new in all aspects. Here is how I installed matplotlib, I'm learning python from pythone crash course book, based on instruction I suppose to install matplotlib on my working folder using pip install from cmd, I erroneously installed it directly in C:\ drive and tried to code, when I got error message I realised the problem, I choosed to recover the issue by doing system restore in my PC, but matplot was not unsinstalled, therefore after seeking help from many source I uninstall it through pip, further I reinstalled it throught pip install in my working folder, the installation was fast as you mentioned within 10 second. My PC processor is Intel(R) Celeron(R) N4000 CPU @ 1.10GHz 1.10 GHz, When I tried to write my first code but got the same message.

In C:\Users\arabu\AppData\Local\Programs\Python\Python312\Lib\site-packages\numpy_core_multiarray_umath. this part is not include: cp312-win_amd64.pyd? Seeking your further help and guidlines to overcome this issue. thank you.

ar1964 commented 1 week ago

Hi Henry, I just realised you are asking about python installation, python was installed on 30 jul 2024, directly downloaded from, python.org site, and I have been using it since then without any issues. this problem started from the day I installed Matplotlib.

ar1964 commented 1 week ago

will it be ok if I uninstall and reinstall python.

henryiii commented 1 week ago

I'd uninstall Python, then delete the C:\Users\arabu\AppData\Local\Programs\Python directory if it still exists. Then you should be fine to reinstall Python. You probably can just delete C:\Users\arabu\AppData\Local\Programs\Python\Python312\Lib\site-packages, then reinstall pip (with py -m ensurepip).

I would highly recommend using virtual environments in the future. Then you can just delete them to restart, and won't have to worry about uninstalling or modifying your base Python installation.