When Import pandas facing issue on my linux server with python 3.12.8

import pandas as pd
File “/home/psoftgl/.local/lib/python3.12/site-packages/pandas/init.py”, line 19, in
raise ImportError(
ImportError: Unable to import required dependencies:
numpy: 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.

What linux distro are you using?
How did you install pandas?

Can you use the systems package installer to install pandas?

i have installed the python 3.12 from OS repository with below command

Yum install python 3.12

Installed packages for pandas and numpy as below
pip3 install numpy-2.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_84.whl -f./ --no index – deps
pip3 install pandas-2.2.3-cp312-cp312-manylinux_2_17_x86_64.whl -f./ --no index – deps

by referred the /home/psoftgl/.local/lib/python3.12/site-packages/pandas/init .py on this this specific error mentioned as if import from source directory befor i have to use the command as python setup.py build_ext.

when i performed this command it was giving error that setup.py is not found file or directory on python 3.12/site packages

Redhat 8 linux

Install pandas from with yum as well and avoid using pip.
You will need to use pip to remove the bad version you have installed.

Rhel 8 is very old and an odd choice for a system you want to run pandas on.

I was checking to install pandas from yum but its showing that no packages were available to install with ? please guide me

Please post text output as preformatted text not screen shots.
I see that numpy is available. Try installing that with dnf and see of you pandas then works.

ok i will try this step and let u know the results. Thanks

in the logs i can see the below error with import numpy ,

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.

Original error was: /home/psoftgl/.local/lib/python3.12/site-packages/numpy/_core/_multiarray_umath.cpython-312-x86_64-linux-gnu.so: failed to map segment from shared object

Could you please check the below logs ?

[psoftgl@clrv0000x GLNEOS92] source ~/.bashrc [psoftgl@clrv0000x GLNEOS92] which python
/opt/PSFT859UC/GLNEOS92/python/python
[psoftgl@clrv0000x GLNEOS92] python --version Python 3.12.3 [psoftgl@clrv0000x GLNEOS92] cd …
[psoftgl@clrv0000x PSFT859UC] cd software/Python_libs/ [psoftgl@clrv0000x Python_libs] ls -ltr
total 32672
-rw-r–r–. 1 psoftgl gl 16116679 Feb 14 13:32 numpy-2.2.3-cp312-cp312-manylinux_2_17_x86_64.whl
-rw-r–r–. 1 psoftgl gl 12739445 Feb 14 13:32 pandas-2.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
-rw-r–r–. 1 psoftgl gl 1841526 Feb 14 13:32 pip-25.0.1-py3-none-any.whl
-rw-r–r–. 1 psoftgl gl 300731 Feb 14 13:32 pypdf-5.3.0-py3-none-any.whl
-rw-r–r–. 1 psoftgl gl 507930 Feb 14 13:35 pytz-2025.1-py2.py3-none-any.whl
-rw-r–r–. 1 psoftgl gl 72494 Feb 14 13:35 wheel-0.45.1-py3-none-any.whl
-rw-r–r–. 1 psoftgl gl 37438 Feb 14 13:35 typing_extensions-4.12.2-py3-none-any.whl
-rw-r–r–. 1 psoftgl gl 11050 Feb 14 13:35 six-1.17.0-py2.py3-none-any.whl
-rw-r–r–. 1 psoftgl gl 1228782 Feb 14 13:35 setuptools-75.8.0-py3-none-any.whl
-rw-r–r–. 1 psoftgl gl 229892 Feb 14 13:40 python_dateutil-2.9.0.post0-py2.py3-none-any.whl
-rw-r–r–. 1 psoftgl gl 346762 Feb 21 07:15 tzdata-2025.1-py2.py3-none-any.whl
-rw-rw-r–. 1 psoftgl gl 0 Feb 21 07:54 setup.py
[psoftgl@clrv0000x Python_libs] pip3 uninstall numpy-2.2.3-cp312-cp312-manylinux_2_17_x86_64.whl Found existing installation: numpy 2.2.3 Uninstalling numpy-2.2.3: Would remove: /home/psoftgl/.local/bin/f2py /home/psoftgl/.local/bin/numpy-config /home/psoftgl/.local/lib/python3.12/site-packages/numpy-2.2.3.dist-info/* /home/psoftgl/.local/lib/python3.12/site-packages/numpy.libs/libgfortran-040039e1-0352e75f.so.5.0.0 /home/psoftgl/.local/lib/python3.12/site-packages/numpy.libs/libquadmath-96973f99-934c22de.so.0.0.0 /home/psoftgl/.local/lib/python3.12/site-packages/numpy.libs/libscipy_openblas64_-6bb31eeb.so /home/psoftgl/.local/lib/python3.12/site-packages/numpy/* Proceed (Y/n)? Y Successfully uninstalled numpy-2.2.3 [psoftgl@clrv0000x Python_libs] pip3 install numpy-2.2.3-cp312-cp312-manylinux_2_17_x86_64.whl
Defaulting to user installation because normal site-packages is not writeable
Processing ./numpy-2.2.3-cp312-cp312-manylinux_2_17_x86_64.whl
Installing collected packages: numpy
Successfully installed numpy-2.2.3
[psoftgl@clrv0000x Python_libs]$ python
Python 3.12.3 (main, May 14 2024, 01:05:25) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44.0.3)] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import numpy
Traceback (most recent call last):
File “/home/psoftgl/.local/lib/python3.12/site-packages/numpy/_core/init.py”, line 23, in
from . import multiarray
File “/home/psoftgl/.local/lib/python3.12/site-packages/numpy/_core/multiarray.py”, line 10, in
from . import overrides
File “/home/psoftgl/.local/lib/python3.12/site-packages/numpy/_core/overrides.py”, line 7, in
from numpy._core._multiarray_umath import (
ImportError: /home/psoftgl/.local/lib/python3.12/site-packages/numpy/_core/_multiarray_umath.cpython-312-x86_64-linux-gnu.so: failed to map segment from shared object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/psoftgl/.local/lib/python3.12/site-packages/numpy/init.py”, line 114, in
from numpy.config import show_config
File “/home/psoftgl/.local/lib/python3.12/site-packages/numpy/config.py”, line 4, in
from numpy._core._multiarray_umath import (
File “/home/psoftgl/.local/lib/python3.12/site-packages/numpy/_core/init.py”, line 49, in
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 “/opt/PSFT859UC/GLNEOS92/python/python.real”
  • The NumPy version is: “2.2.3”

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

Original error was: /home/psoftgl/.local/lib/python3.12/site-packages/numpy/_core/_multiarray_umath.cpython-312-x86_64-linux-gnu.so: failed to map segment from shared object

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

Traceback (most recent call last):
File “”, line 1, in
File “/home/psoftgl/.local/lib/python3.12/site-packages/numpy/init.py”, line 119, in
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.

Did you try installing numpy with dnf as I think I recommended?
Using pip will mean you need all the development tools and libraries installed.