Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64') #3171

Open
HuaYuXiao opened this issue Jun 28, 2023 · 3 comments

Comments

@HuaYuXiao
Copy link

Mac version: MacBook Pro M1 2020
MacOS: 13.4.1
python version: 3.11.3

Traceback (most recent call last):
File "/Users/hyx020222/Library/Mobile Documents/comappleCloudDocs/project/NLP/main.py", line 1, in
import nltk
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nltk/init.py", line 138, in
from nltk.text import *
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nltk/text.py", line 29, in
from nltk.tokenize import sent_tokenize
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nltk/tokenize/init.py", line 65, in
from nltk.tokenize.casual import TweetTokenizer, casual_tokenize
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nltk/tokenize/casual.py", line 49, in
import regex # #2409
^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/regex/init.py", line 1, in
from .regex import *
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/regex/regex.py", line 421, in
import regex._regex_core as _regex_core
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/regex/_regex_core.py", line 21, in
import regex._regex as _regex
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/regex/_regex.cpython-311-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/regex/_regex.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/regex/_regex.cpython-311-darwin.so' (no such file), '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/regex/_regex.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))

@HuaYuXiao HuaYuXiao changed the title ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/regex/_regex.cpython-311-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/regex/_regex.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/regex/_regex.cpython-311-darwin.so' (no such file), '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/regex/_regex.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')) ImportError: mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64') Jun 28, 2023
@malinamedusa
Copy link

(lovenv) malinamedusa@MacBook-Pro test-task-for-Aero % python3 load_data_in_table.py
Traceback (most recent call last):
File "/Users/malinamedusa/PycharmProjects/test-task-for-Aero/lovenv/lib/python3.12/site-packages/requests/compat.py", line 11, in
import chardet
ModuleNotFoundError: No module named 'chardet'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/malinamedusa/PycharmProjects/test-task-for-Aero/load_data_in_table.py", line 1, in
from connector import LoadingDataHTTPtoPG
File "/Users/malinamedusa/PycharmProjects/test-task-for-Aero/connector.py", line 2, in
import requests
File "/Users/malinamedusa/PycharmProjects/test-task-for-Aero/lovenv/lib/python3.12/site-packages/requests/init.py", line 45, in
from .exceptions import RequestsDependencyWarning
File "/Users/malinamedusa/PycharmProjects/test-task-for-Aero/lovenv/lib/python3.12/site-packages/requests/exceptions.py", line 9, in
from .compat import JSONDecodeError as CompatJSONDecodeError
File "/Users/malinamedusa/PycharmProjects/test-task-for-Aero/lovenv/lib/python3.12/site-packages/requests/compat.py", line 13, in
import charset_normalizer as chardet
File "/Users/malinamedusa/PycharmProjects/test-task-for-Aero/lovenv/lib/python3.12/site-packages/charset_normalizer/init.py", line 24, in
from .api import from_bytes, from_fp, from_path, is_binary
File "/Users/malinamedusa/PycharmProjects/test-task-for-Aero/lovenv/lib/python3.12/site-packages/charset_normalizer/api.py", line 5, in
from .cd import (
File "/Users/malinamedusa/PycharmProjects/test-task-for-Aero/lovenv/lib/python3.12/site-packages/charset_normalizer/cd.py", line 14, in
from .md import is_suspiciously_successive_range
ImportError: dlopen(/Users/malinamedusa/PycharmProjects/test-task-for-Aero/lovenv/lib/python3.12/site-packages/charset_normalizer/md.cpython-312-darwin.so, 0x0002): tried: '/Users/malinamedusa/PycharmProjects/test-task-for-Aero/lovenv/lib/python3.12/site-packages/charset_normalizer/md.cpython-312-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/malinamedusa/PycharmProjects/test-task-for-Aero/lovenv/lib/python3.12/site-packages/charset_normalizer/md.cpython-312-darwin.so' (no such file), '/Users/malinamedusa/PycharmProjects/test-task-for-Aero/lovenv/lib/python3.12/site-packages/charset_normalizer/md.cpython-312-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
(lovenv) malinamedusa@MacBook-Pro test-task-for-Aero % arch
arm64

I have the same problem although I have arm64
found it here https://dotnet.microsoft.com/en-us/download

@Higgs32584
Copy link

I got the same issue

@rmalouf
Copy link
Contributor

rmalouf commented Mar 5, 2024

These don't appear to be problems with NLTK. The first is a problem with regex and the second is a problem with charset_normalizer which is a dependency of requests. And for both of the issue appears to be that you're running python under rosetta 2 but had installed the libraries in native apple silicon mode, or vice versa.

Do you get these same errors with a fresh install of python and NLTK?

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

No branches or pull requests

4 participants