Numpy wont run on Apple iMac M1 using ARM64

Using Apple iMac M1 and running Python 3.12.0. Python works as expected however, whilst numpy, matplotlib, etc installed apparently successfully using conda the numpy module (etc) isnt recognised in python programs. Believe this is because numpy (and other modules) have not yet successfully been updated to run on native ARM64 chips. Have others also found this to be a problem?

Numpy (1.26.0) and matplotlib (3.8.1) both work in Python3.12 on MacOS arm64 (I’m using an M2; M1 will also work). Why do you believe that “the numpy modules isn’t recognized”?

Hi again,

As stated i’m working OK now in Python 3.12. I’ve tried installing numpy using conda and it appears to work, however each time it says conda version out of date, please update which I do using given command. Update appears OK, but using conda install numpy again, exactly the same message is given about conda update required. I also tried using pip3 and made sure this was updated to the current version. Used pip3 install numpy and again it states ‘requirement already satisfied’. I used a simple numpy test program (see image) which was created using vim editor (in Terminal 3.12) and saved in (my username) Project-1 (created using Mkdir). Tried running this test program either using Python Launcher, which I now see is version 3.12, and also in IDLE 3.12. In both cases the error message is "ModuleNotFoundError: No module named ‘numpy’ "

I think you’ve installed multiple copies of Python. One version is where you’re running IDLE and one or more via conda (which is where you installed numpy).

To test your script in the conda environment, try invoking it from the command line instead of in IDLE. It should look like this:

(py312) alancormier@alans-iMac ~ % python ~/project-1/

In the first part of the screenshot, you show using conda to activate a Python 3.12 environment, upgrade its Pip, and install Numpy for it. However, this environment is, apparently, completely separate from the Python 3.12 environment that IDLE is in - even though it happens to be the same version of Python. It is basically the same as if you had two copies of any other program on your computer, with their own separate config files that are local to the executable; edited one config file; and expected the other copy of the program to notice. Each Python gets its own place to install third-party libraries (such as Numpy), its own Pip*, its own IDLE*, etc.

To verify this, try import sys and then sys.executable in the IDLE shell. I expect you will see a different path from the one where the conda environment was created (./opt/anaconda3/envs/py312 etc.).

IDLE is quite basic. It’s designed to use the Python that it came with, and as far as I know this cannot be changed. The environment that you show active in the terminal should have its own IDLE, which you should be able to access from the same terminal window, while the environment is active, using something like python -m idlelib &. But whatever IDLE you already had open, or opened in a different way, could well be something else.

* Some distributions of Python - especially one that came with your computer on a Linux-based system - may omit some or all of these. As far as I know, a newly created Conda environment would normally have IDLE by default. I don’t know if Conda leaves out Pip, seeing as how it tries to do Pip’s job (among other things). I haven’t actually used Conda.

You’re meant to install into Anaconda with conda, not pip3.

You got a “ModuleNotFoundError” for a module (package) that you thought you installed.
The question then is: Why did Python not find the module that you’re sure you installed?
To answer this you need to know: How does Python search for modules?
If you look in the Python docs, you’ll find this documented in 6. Modules — Python 3.12.0 documentation
and The initialization of the sys.path module search path — Python 3.12.0 documentation

To be sure - those docs may not be easy-reading if you are just beginning with Python. But when you google that question, you’ll also find lots of user-friendly tutorials.

As to using pip and conda - when you start using conda, there is some really important high-level background info and some info specific for pip that you need to be aware of:

In practical use, inside a conda env its advisable not to use pip, unless you have no choice. The highlevel reason for this is explained in the link above. (Neglecting this can lead to conda envs that become inconsistent and unusable. That’s not a huge issue, since you can always easily wipe it - but it’s a bit of pain when you need to re-install lots of packages.)

1 Like

Hi again,

Finally got to a solution. It appeared that Anaconda (conda) was causing me a problem. After completely removing anaconda, reinstalling Python 3.12 (from and subsequently pip3, I could install numpy and matplotlib usin pip3. Checking the Python version in Terminal (python3 --version) showed the required Python 3.12 and simple test programs in (Mkdir) Project-1 for numpy and matplot lib worked perfectly as expected when dragged to Python Launcher.

I hope that you still read the thread and links within it so you’ll understand why this was the issue. You might need to use conda (or something like it) in the future.

Hello again,

Whilst I have now achieved my original aim (ie to use Python 3.12 in conjunction with numpy and matplotlib) I am always looking to increase my knowledge in all areas. One key issue I have at the moment is to fully understand why achieving the same goal using conda (either Anaconda, miniconda or miniforge) would be advantageous in my case. It appears that whilst both the pip and conda routes are broadly similar, which selection is best appears “best determined by the end users usage and requirements”, whatever this means. Key differences which appear apparent (correct me if i’m wrong) are that Python, numpy and matplotlib pip installs are independent; by using conda all packages are linked (simlinked, is that the right word) so that all packages are maintained such that they all consistently work together. It also appears that each particular package combination is located in a specific ‘environment’. So if a different version of say Python is required, one needs to access that particular environment. I can see that this might be useful where for example a new major upgrade to Python is available, but old programs will only run correcly on the earlier Python version.
I’m keeping with the pip version for now as its taken long enough to get that method working. I have looked again, however, at the latest Anaconda download package for M1, M2 2023 and there appeared to be a problem here in that whilst the 2022 package (*.pkg file) could be dragged to Applications folder in finder (and hence to program load), in the 2023 package case the package cannot be opened as it is from an unidentified developer? Not sure whats going on here (the original Anaconda version I tried was 2022). The alternative may be miniconda or miniforge but I haven’t, and wont be, tring these yet.
It would inded be useful to increase my knowledge in the use of Environments, however most articles I have found on the web are not very illuminating. Perhaps you can help?

Hi - You’re really raising a new issue here, so it may be better to open a different thread for this.

For these kind of very general questions, it turns out that for instance ChatGPT (3.5, free version) is reliable. It’s true that ChatGPT can still give misleading or totally bogus answers to technical questions -especially to specific questions about advanced algorithms or very specific domains, but for the following questions:

  • What are Python environments?
  • When are conda environments useful?
  • MacOS gives a warning “cannot be opened because it is from an unidentified developer”. What does this mean?
  • Whilst both the pip and conda routes are broadly similar, which selection is best appears “best determined by the end users usage and requirements”. What does this mean?

its answers are correct, helpful, and may contain follow-up hints. So, you might consider using it (unless you are in principle against doing so).

As a beginner in this domain you may not always be able to determine whether an answer is reliable. But imo it still can help speed up discovery - Taking whatever it tells you, you can either follow up with a search in official docs (which will be faster since more focused), or you can just try it out and see what happens.