pythonpandasmacosnumpypycharm

Python packages installation - pandas & nympy


I have read close to all posts about this topic now but I can get it working, so sorry if you find this similar to other questions, but I can't just solve it based on existing posts. I find it very hard to install Python with its packages, and remember struggling on my PC a couple of years ago also.

I have a macbook. I have installed python. Using PyCharm. I have tried to install a couple of packages, not sure they got installed in the right or wrong folder. So far I have tried (and in some cases been successful) installing requests, torch, wheel, pandas, numpy. All by using pip. I have tried uninstall and install again. Also tried upgrading.

Line 8 in the response below is "import pandas as pd"

The code in PyCharm gives the following response during execution: File "/Users/name/PycharmProjects/ABCProject/file.py", line 8, in import pandas as pd File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/site-packages/pandas/init.py", line 19, in raise ImportError( "Unable to import required dependencies:\n" + "\n".join(_missing_dependencies) ) ImportError: Unable to import required dependencies: numpy:

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. The following compiled module files exist, but seem incompatible with with either python 'cpython-314' or the platform 'darwin':

We have compiled some common reasons and troubleshooting tips at:

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

Please note and check the following:

and make sure that they are the versions you expect.

Please carefully study the information and documentation linked above. This is unlikely to be a NumPy issue but will be caused by a bad install or environment on your machine.

Original error was: No module named 'numpy._core._multiarray_umath'

Process finished with exit code 1


Solution

  • When you run pip install pandas it automatically installs the latest compatible version of numpy since Pandas is built on top of Numpy.

    Questions:

    Deep Leaning libraries like PyTorch(torch) or PyTorch-Geometric (for graph neural networks) tend to lang 1 or 2 major Python versions. Specially if you use GPU accelerated training.

    I've been using Python 3.12 for the last month with all the pip packages you mentioned without any issues.

    If you are okay with downgrading to 3.12 here is a step by step solution to your problem.

    Steps:

    1. Remove Python 3.14: For Mac I recommend AppCleaner to make sure all files related to Python are removed.

    2. Install Python 3.12: You can do this from terminal using brew: brew install python@3.12 or directly from Pythons website here: https://www.python.org/downloads/release/python-31212/

    3. Check install: From terminal run python3 --version or python --version to make sure you now have 3.12.xx

    4. Create a virtual environment: Navigate to a new directory, create a virtual environment with python3 -m venv .venv or python -m venv .venv. Run ls -a if you see a .venv dir then it worked fine.

    5. Activate/Source your environment: To activate your environment run, source .venv/bin/activate

    6. Install pip packages: you can either create a requirements.txt file and place your package names there or just install them one by one.

    7. Start with pip3 install torch and test it before moving onto the next. Try the pip flag --no-cache if you need to uninstall/install packages in the future.

    Notes:

    Since you have a MacBook, check if you have an M-Chip or M-series chip. You may be to leverage your GPU for training using MPS. Check out https://developer.apple.com/metal/pytorch/ for details. GPU accelerated training is significantly faster than CPU.