Skip to content
This repository was archived by the owner on Jun 9, 2021. It is now read-only.

Can not install tensorflow for macos BigSur(M1) . Python version : 3.8.7. I am trying on an virtual environment. #168

Open
KarriKarthik opened this issue Feb 13, 2021 · 2 comments

Comments

@KarriKarthik
Copy link

import tensorflow as tf
Traceback (most recent call last):
File "/Users/karrikarthik/Documents/VS_Code_prog/Python_trial_3/my_env/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 64, in
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: dlopen(/Users/karrikarthik/Documents/VS_Code_prog/Python_trial_3/my_env/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): no suitable image found. Did find:
/Users/karrikarthik/Documents/VS_Code_prog/Python_trial_3/my_env/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture
/Users/karrikarthik/Documents/VS_Code_prog/Python_trial_3/my_env/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/Users/karrikarthik/Documents/VS_Code_prog/Python_trial_3/my_env/lib/python3.8/site-packages/tensorflow/init.py", line 41, in
from tensorflow.python.tools import module_util as _module_util
File "/Users/karrikarthik/Documents/VS_Code_prog/Python_trial_3/my_env/lib/python3.8/site-packages/tensorflow/python/init.py", line 39, in
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
File "/Users/karrikarthik/Documents/VS_Code_prog/Python_trial_3/my_env/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 83, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/Users/karrikarthik/Documents/VS_Code_prog/Python_trial_3/my_env/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 64, in
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: dlopen(/Users/karrikarthik/Documents/VS_Code_prog/Python_trial_3/my_env/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): no suitable image found. Did find:
/Users/karrikarthik/Documents/VS_Code_prog/Python_trial_3/my_env/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture
/Users/karrikarthik/Documents/VS_Code_prog/Python_trial_3/my_env/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture

Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.

@mwidjaja1
Copy link

Refer to issue #146

@Prashant-Kesharwani
Copy link

You can install all the following modules by creating a Virtual Environment, and then installing all these modules inside that Virtual Environment.

1. Install Matplotlib

1.1 Install Homebrew
Type in your terminal (not in rosetta environment):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then add homebrew's path to the variable path:

echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/bcghostpc/.zprofile eval $(/opt/homebrew/bin/brew shellenv)

1.2 Install libjpeg

brew install libjpeg

1.3 Install Matplotlib

In the virtual environment, type:

pip install matplotlib

2. Install tensorflow

Type in terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/apple/tensorflow_macos/master/scripts/download_and_install.sh)"
then name your virtual environment's folder

3. Install pandas

In your virtual environment, type:

pip install cython
git clone https://github.com/pandas-dev/pandas.git
cd pandas
python3 setup.py install

4. Install jupyter notebook

In your virtual environment, type:

pip install notebook
Then go to lib/python3.8/site-packages/ipykernel

Edit the eventloops.py file using nano eventloops.py

In the _use_appnope() function, edit the return line as follows:

return sys.platform == 'darwin' and V(platform.mac_ver()[0]) >= V('10.9') and platform.mac_ver()[2] != 'arm64'

Appendix

About Installing Different Modules
You can install any module using pip inside Virtual Environment:

pip install <moduleName>

About Virtual Environment

You can create a virtual environment by:

python3 -m venv <name>
After creating the environment, you can activate the environment by:

source <name>/bin/activate
To exit the environment, type:

deactivate

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants