1

I have recently purchased M1 Pro MacBook and wanted to take the Tensorflow certification exam, but I am facing the errors while importing the Tensorflow in PyCharm.

Below are the steps I followed as per Tensorflow guideline:

  1. Install Python 3.8:
  2. Install PyCharm 2021.3:
  3. Created the project in PyCharm
  4. Installed below python dependencies as per guideline:
tensorflow==2.7
tensorflow-datasets==4.6.0
Pillow==9.1.1
pandas==1.4.2
numpy==1.22.4
scipy==1.7.3

Now when I import tensorflow in python script, it throws: Process finished with exit code 132 (interrupted by signal 4: SIGILL) error.

I searched the above mentioned error and found there is some issue the architecture of the python interpreter and tensorflow. But I have installed both python and pycharm of x86_64 architecture.

  • Are you running the Python script from the terminal? In this case, there might be more information available on the error. – Mikko Ohtamaa Aug 18 '22 at 09:33
  • @MikkoOhtamaa `zsh: illegal hardware instruction python3 main.py` this is the error I am getting when I run the script from terminal. And ```/Users/hemendra/PycharmProjects/pythonProject/venv/bin/python /Users/hemendra/PycharmProjects/pythonProject/main.py Process finished with exit code 132 (interrupted by signal 4: SIGILL)``` is the error message when I run the script from PyCharm. – Hemendra Singh Rajawat Aug 18 '22 at 10:13
  • https://stackoverflow.com/questions/65383338/zsh-illegal-hardware-instruction-python-when-installing-tensorflow-on-macbook – Mikko Ohtamaa Aug 18 '22 at 10:14
  • 1
    @MikkoOhtamaa while taking the tensorflow certification exam, tensorflow plugin will create new env and install tensorflow. At time time, will I be able to manually install tensorflow using wheel as mentioned in the provided link? And where I can find the tensorflow==2.7 link? In the link only 2.4 link is given. – Hemendra Singh Rajawat Aug 18 '22 at 10:29
  • Unfortunately I do not have experience with tensorflow to guide you, only with PyCharm. My suggestion is that if it is an exam then the exam organisers need to provide you the required support to make sure all participants can easily set up and replicate the environment. – Mikko Ohtamaa Aug 18 '22 at 13:31
  • You can install a specific version of tensorflow in your environment with the instruction `pip install tensorflow==2.7` – ClaudiaR Aug 19 '22 at 16:33
  • @ClaudiaR when I used `pip install tensorflow==2.7` I am getting `Process finished with exit code 132 (interrupted by signal 4: SIGILL)` error. – Hemendra Singh Rajawat Aug 19 '22 at 16:44
  • During the installation or after? Also I've opened the linked instructions and they actually suggest installing tensorflow==2.9.0 – ClaudiaR Aug 19 '22 at 16:48
  • @ClaudiaR tensorflow installation is successful but the error comes during the import in python script as mentioned in the initial question. – Hemendra Singh Rajawat Aug 19 '22 at 18:12
  • Okay let me know if setting up the environment as suggested in my answer works – ClaudiaR Aug 19 '22 at 18:17

1 Answers1

0

Have you seen this GitHub thread?

They suggest updating the certificates for example like this:

open /Applications/Python\ 3.7/Install\ Certificates.command

Sorry I cannot test it, I don't have an M1, and apparently this error happens under Apple Silicon. See if it works.


Info on how to setup an environment through PyCharm:

  1. Create a project
  2. Go to the right bottom corner of the window and press <No interpreter> and then Add Interpreter. You'll find different ways to create an environment. I suggest you to use Conda if you have it or Virtualenv. Either way select "new environment". Select the location and the python version. Press Ok. Now you have an environment where you can install all your packages.
  3. Wait for PyCharm to terminate building everything.
  4. Go to the terminal tab. You should be inside the environment. You can verify it looking on the left side of the path. You should see something like (your_env_name) before the path.
  5. Install all the packages listed with pip install inside the terminal.
ClaudiaR
  • 3,108
  • 2
  • 13
  • 27