0

I am having a problem when trying to import tensorflow. I am running python 3.8:

Python 3.8.13 (default, Oct 19 2022, 17:54:22) 
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

I installed tensorflow 2.10 inside a conda enviroment:

pip install tensorflow

I imagine I am not installing the proper version of tensorflow for the M2? Any idea how to solve this?

Note: I have tried https://www.mrdbourke.com/setup-apple-m1-pro-and-m1-max-for-machine-learning-and-data-science/

and other options including "zsh: illegal hardware instruction python" when installing Tensorflow on macbook pro M1

but no luck so far.

edgarbc
  • 366
  • 2
  • 15
  • 1
    Does this answer your question? ["zsh: illegal hardware instruction python" when installing Tensorflow on macbook pro M1](https://stackoverflow.com/questions/65383338/zsh-illegal-hardware-instruction-python-when-installing-tensorflow-on-macbook) – Pouya Esmaeili Nov 11 '22 at 20:22
  • Thanks for the suggestion. I tried several options for the M1 (including that one) and no luck so far. – edgarbc Nov 11 '22 at 20:46
  • 1
    Please try by changing some settings in your system as mentioned in this [link](https://code2care.org/zsh/zsh-illegal-hardware-instructions-python-tenserflow-m1-mac)? or can Create a virtual environment with Python 3.8 in conda environment and then install tensorflow using `pip install tensorflow-aarch64`,`pip install tensorflow-macos`. Please check this [link](https://developer.apple.com/metal/tensorflow-plugin/) for more details in this. –  Dec 07 '22 at 15:14

1 Answers1

0

I have downloaded and installed tensorflow via this link.

These were my installation steps:

  • install a venv: python3 -m venv venv.
  • drag the (which is located within the downloaded folder) file to the terminal, add at the end. install_venv.sh-p
  • Select the directory of the venv as the location where tensorflow should be installed.
  • activate the venv.
  • type "python".
  • try to import tensorflow: .import tensorflow as tf

I'm using Python 3.8.2.

Faisal Shahbaz
  • 431
  • 3
  • 12