【环境踩坑】MAC M1安装 mysqlclient 报错
ImportError: dlopen(/Usersopt/anaconda3/lib/python3.9/site-packages/MySQLdb/_mysql.cpython-39-darwin.so, 2): Symbol not found: _mysql_affected_rows报错2:Traceback (most recent call last):File ““, line 1
报错1:
ImportError: dlopen(/Usersopt/anaconda3/lib/python3.9/site-packages/MySQLdb/_mysql.cpython-39-darwin.so, 2): Symbol not found: _mysql_affected_rows
报错2:
Traceback (most recent call last):
File “<stdin>“, line 1, in <module>
File “/Users/dxxxlib/python3.9/site-packages/MySQLdb/__init__.py”, line 24, in <module>
version_info, _mysql.version_info, _mysql.__file__
NameError: name ‘_mysql’ is not defined
具体忘记是先报的那个错,总之就是这俩解了一个回报另一个,这里主要说【NameError: name ‘_mysql’ is not defined】的解法:
// 我没执行完这一步,自己本机的 brew 是 OK 的,这一步执行时间太长了。。。可以先直接后面的,如果不报错说明你自己的brew 本身也是 OK 的
mkdir homebrew-x86 && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew-x86
arch -x86_64 homebrew-x86/bin/brew install mysql-client@5.7
export LDFLAGS="-L/Users/xx/homebrew-x86/opt/mysql-client@5.7/lib" >> /Users/xx/.bash_profile
export CPPFLAGS="-I/Users/xx/homebrew-x86/opt/mysql-client@5.7/include" >> /Users/xx/.bash_profile
export PKG_CONFIG_PATH="/Users/xx/homebrew-x86/opt/mysql-client@5.7/lib/pkgconfig" >> /Users/xx/.bash_profile
arch -x86_64 pip install --no-cache-dir --force-reinstall mysqlclient
解决啦~
Reference:
https://github.com/PyMySQL/mysqlclient/issues/496
更多推荐
所有评论(0)