asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.22k stars 1.24k forks source link

mach-o file, but is an incompatible architecture (have (arm64), need (x86_64)) #726

Open sQur1 opened 2 years ago

sQur1 commented 2 years ago

I'm trying to take a screenshot and I get an error from PIL somehow... even though I use PIL in other projects without having this error thrown at me. I've installed and re-install the virtual environment, same result.

Hardware: Macbook Pro M1 2020 Software: VS Codium

Code:

import pyautogui
from PIL import Image
pyautogui.screenshot(region=(1182,1143, 1695, 1254))

Full code error:

Traceback (most recent call last):
  File "/Users/sqrl/Desktop/python_projects/free_subs/main.py", line 2, in <module>
    from PIL import Image
  File "/Users/sqrl/Desktop/python_projects/free_subs/venv/lib/python3.10/site-packages/PIL/Image.py", line 100, in <module>
    from . import _imaging as core
ImportError: dlopen(/Users/sqrl/Desktop/python_projects/free_subs/venv/lib/python3.10/site-packages/PIL/_imaging.cpython-310-darwin.so, 0x0002): tried: '/Users/sqrl/Desktop/python_projects/free_subs/venv/lib/python3.10/site-packages/PIL/_imaging.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have (arm64), need (x86_64)))
pvani6 commented 1 year ago

Hi, am facing the same issue while trying to import the pandas.

import pandas

error i'm getting,

ImportError: dlopen(/Library/Python/3.9/lib/python/site-packages/pandas/_libs/interval.cpython-39-darwin.so, 0x0002): tried: '/Library/Python/3.9/lib/python/site-packages/pandas/_libs/interval.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have (arm64), need (x86_64)))

davidarndt commented 1 year ago

Last time I checked, pyautogui has not been updated to work on arm64. If you're on a Mac using Apple Silicon, you can set up an x86 Python environment using instructions such as found here: https://towardsdatascience.com/how-to-manage-conda-environments-on-an-apple-silicon-m1-mac-1e29cb3bad12

patrick-melo commented 1 year ago

I had the same problem. When I downloaded PyCharm, I didn't notice that the Mac version actually has two versions listed, the Intel version and the Apple Silicon version. The website defaulted to the Intel version (pycharm-professional-2022.3.2.dmg). I went back to the site and downloaded the Apple Silicon Version (pycharm-professional-2022.3.2-aarch64.dmg), remove the one I had installed and installed the new version. That fixed my problem. I hope this works for you.