M1 architecture issue

I have an M1 MacBook Air! I tried installing 'keras' and 'tensorflow' packages in Rstudio. However I got an error. Then, I tried creating a virtual env to work in it and my script did run for a couple of hours but then it's again back to the same error:

Error in py_initialize(config$python, config$libpython, config$pythonhome, : /Users/mansichandra/mambaforge/envs/walnut/lib/libpython3.8.dylib - dlopen(/Users/mansichandra/mambaforge/envs/walnut/lib/libpython3.8.dylib, 10): no suitable image found. Did find: /Users/mansichandra/mambaforge/envs/walnut/lib/libpython3.8.dylib: mach-o, but wrong architecture /Users/mansichandra/mambaforge/envs/walnut/lib/libpython3.8.dylib: mach-o, but wrong architecture

How can this be resolved because I'm pretty sure it's an architecture problem!!

Replies

Hi @Mansi_Chandra, can you please provide the installation steps to reproduce the issue? Its possible during installation of Python packages (or their dependents) the x86 version of the package was installed which led to this issue. To know the architecture of the dylib, you can paste the output of :

lipo -info /Users/mansichandra/mambaforge/envs/walnut/lib/libpython3.8.dylib

Hello, I've got similar problem about this..

Traceback (most recent call last):
 File "/opt/homebrew/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 25, in <module>
  import psycopg2 as Database
 File "/opt/homebrew/lib/python3.9/site-packages/psycopg2/__init__.py", line 51, in <module>
  from psycopg2._psycopg import (           # noqa
ImportError: dlopen(/opt/homebrew/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so, 2): no suitable image found. Did find:
	/opt/homebrew/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so: mach-o, but wrong architecture
	/opt/homebrew/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so: mach-o, but wrong architecture

The output of this command

lipo -info /opt/homebrew/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so

is:

Non-fat file: /opt/homebrew/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so is architecture: x86_64

I am running on MacBook Pro M1, Big Sur 11.5.2 The error came while running this command:

python3 manage.py startapp app_name

Is there a hope to fix that?