0

So I'm trying to install the package here: https://github.com/Technologicat/pydgq/blob/master/README.md

git clone https://github.com/Technologicat/pydgq.git
cd pydgq
sudo python setup.py install

(opt) vogtster@Vogtsters-Mini pydgq % cd ..
(opt) vogtster@Vogtsters-Mini Finite Element % cd pydgq/test 
(opt) vogtster@Vogtsters-Mini test % python lorenz_example.py 
zsh: illegal hardware instruction  python lorenz_example.py
(opt) vogtster@Vogtsters-Mini test % python
Python 3.7.13 (default, Mar 28 2022, 07:24:34) 
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pydgq
zsh: illegal hardware instruction  python

Looking around I found a thread here which this issue was happening for tensorflow: "zsh: illegal hardware instruction python" when installing Tensorflow on macbook pro M1

The only difference is I have a mac-mini with a M1 chip, which makes me believe this is the issue. However, I could not figure out how to resolve this issue to make the code run.

I suspect somehow I have to run some of these commands with some special flag to make everything work. Any suggestions would be greatly appreciated!

Perhaps this thread can become a "1 catch all question" of how to resolve this issue in general.

Thank you

Eigenvalue
  • 1,093
  • 1
  • 14
  • 35
  • 1
    It wasn't until the May 2022 release that Anaconda natively supported M1. Looks like you have a version of Anaconda earlier than that. If you try to use an x86-64 Anaconda to run a Python module compiled for M1, you'll probably have issues like this. – jjramsey Jul 25 '22 at 20:00
  • I've got Anaconda running on a MacBook M1. – duffymo Jul 25 '22 at 20:23

1 Answers1

0

this worked for me.

Step 1 Using pyenv install python version 3.8.5 and set it as your default python version. This tutorial(https://realpython.com/intro-to-pyenv/) is helpful for getting pyenv configured properly.

Step 1.1 Use this post(https://github.com/pyenv/pyenv/issues/1446) if you have troubles running pyenv in zsh.

Step 1.2 Once you have python version 3.8.5 running which you can check by running python -V which should output:

Python 3.8.5

Step 2 Install virtualenv via pip install virtualenv

Step 2.1 Create a virtual environment by running virtualenv ENV

Step 2.2 Activate that virtual environment by running source ENV/bin/activate

Step 3 Install the tensorflow wheel called tensorflow-2.4.1-py3-none-any.whl located at this public google drive link https://drive.google.com/drive/folders/1oSipZLnoeQB0Awz8U68KYeCPsULy_dQ7

Step 3.1 Assuming you simply installed the wheel to downloads run pip install ~/Downloads/tensorflow-2.4.1-py3-none-any.whl in your activated virtual environment

Step 4 Type python which will bring up >>>in your terminal and type

import tensorflow

If there is no 'zsh illegal hardware instruction" error you should be good to go.

Note: If you're using Anaconda, the above will also work. You can skip the virtual env stages (if you have a virtual env configured using Conda) and proceed directly to the pip install (steps 3 and later).

Faisal Shahbaz
  • 431
  • 3
  • 12