提问人:Pay Enzo 提问时间:10/17/2023 最后编辑:Pay Enzo 更新时间:10/18/2023 访问量:103
谁能帮我在pymysql上解决这个问题
Can anyone help me with this problem on pymysql
问:
我试图使用pymysql连接到mysql服务器,但是当我导入它时,它抛出了一个错误。
它打印
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/_cffi_backend.cpython-310-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/_cffi_backend.cpython-310-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.10/lib/python3.10/site-packages/_cffi_backend.cpython-310-darwin.so' (no such file), '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/_cffi_backend.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
thread '<unnamed>' panicked at 'Python API call failed', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-0.18.3/src/err/mod.rs:790:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
File "/usr/local/mysql-8.0.29-macos12-x86_64/etc/Desktop/编程学习/MySQL/test.py", line 1, in <module>
import pymysql
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pymysql/__init__.py", line 78, in <module>
from . import connections # noqa: E402
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pymysql/connections.py", line 13, in <module>
from . import _auth
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pymysql/_auth.py", line 9, in <module>
from cryptography.hazmat.primitives import serialization, hashes
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/cryptography/hazmat/primitives/serialization/__init__.py", line 7, in <module>
from cryptography.hazmat.primitives._serialization import (
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/cryptography/hazmat/primitives/_serialization.py", line 11, in <module>
from cryptography.hazmat.primitives.hashes import HashAlgorithm
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/cryptography/hazmat/primitives/hashes.py", line 10, in <module>
from cryptography.hazmat.bindings._rust import openssl as rust_openssl
pyo3_runtime.PanicException: Python API call failed
我真的不知道这个,因为我以前从未见过它。 谁能帮我解决这个问题? 而且我可以在Mac的终端上运行数据库。
答:
0赞
Fardad Ansari
10/18/2023
#1
1.首先检查您的python版本,然后检查兼容性64位或32位 2.安装mysql.connector模块而不是pymysql(mysql-connector-python)
评论
0赞
Pay Enzo
10/18/2023
谢谢你的回答,这真的很有帮助! !👍
评论
cffi
cffi