![](/img/trans.png)
[英]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.