[英]m1 mac, python assertion failure and crashes when using osx as backend in matplotlib & jupyter notebook
[英]Name '_mysql' is not defined on M1 Mac using jupyter notebook
我正在嘗試在蘋果硅 mac 上運行一個 jupyter 筆記本,並且進行了大量的故障排除。 最新的問題是:我用 pip 安裝了必要的庫,但程序無法識別它們。 pandas 和 numpy 也發生了同樣的事情,它們在安裝 anaconda(但沒有 pip)后開始工作。 這是堆棧跟蹤:
ImportError Traceback (most recent call last)
/opt/homebrew/lib/python3.9/site-packages/MySQLdb/__init__.py in <module>
17 from MySQLdb.release import version_info
---> 18 from . import _mysql
19
ImportError: dlopen(/opt/homebrew/lib/python3.9/site-packages/MySQLdb/_mysql.cpython-39-darwin.so, 2): no suitable image found. Did find:
/opt/homebrew/lib/python3.9/site-packages/MySQLdb/_mysql.cpython-39-darwin.so: mach-o, but wrong architecture
/opt/homebrew/lib/python3.9/site-packages/MySQLdb/_mysql.cpython-39-darwin.so: mach-o, but wrong architecture
During handling of the above exception, another exception occurred:
NameError Traceback (most recent call last)
/var/folders/nq/fmv846f95p519gmbd0fc2nj40000gn/T/ipykernel_915/3639928363.py in <module>
4 import numpy
5 import pandas as pd
----> 6 import MySQLdb
/opt/homebrew/lib/python3.9/site-packages/MySQLdb/__init__.py in <module>
22 raise ImportError(
23 "this is MySQLdb version {}, but _mysql is version {!r}\n_mysql: {!r}".format(
---> 24 version_info, _mysql.version_info, _mysql.__file__
25 )
26 )
NameError: name '_mysql' is not defined
會發生什么? 請幫忙
即使我的回答已經很晚了,我仍然想在這里分享我目前的解決方法。
我在 OEL8 上遇到了同樣的問題。 但是我發現了一個奇怪的解決方法。 “NameError: name '_mysql' is not defined”僅在 pandas 或在我的情況下也是 seaborn 在 MySQLdb 之前導入時發生。 MySQLdb 和數據科學庫之間似乎存在沖突。 一旦找到適當的解決方案或對此行為的解釋,我將立即更新我的回復。
>>> import pandas
>>> import MySQLdb
Traceback (most recent call last):
File "/usr/lib64/python3.9/site-packages/MySQLdb/__init__.py", line 18, in <module>
from . import _mysql
ImportError: /lib64/libstdc++.so.6: cannot allocate memory in static TLS block
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.9/site-packages/MySQLdb/__init__.py", line 24, in <module>
version_info, _mysql.version_info, _mysql.__file__
NameError: name '_mysql' is not defined
>>> import MySQLdb
>>> import pandas
>>>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.