MAC Reason: image not found

   在mac 上python3 连接mqsql 数据库时候,安装mysqlclient  导包 MySQLdb 运行则会报错:

return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 994, in _gcd_import
  File "", line 971, in _find_and_load
  File "", line 955, in _find_and_load_unlocked
  File "", line 665, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 219, in _call_with_frames_removed
  File "/Users/gengli/code/ltgScrapy/ltgScrapy/pipelines.py", line 11, in
    import MySQLdb
  File "/Users/gengli/code/venv/lib/python3.6/site-packages/MySQLdb/__init__.py", line 18, in
    from . import _mysql
ImportError: dlopen(/Users/gengli/code/venv/lib/python3.6/site-packages/MySQLdb/_mysql.cpython-36m-darwin.so, 2): Library not loaded: @rpath/libmysqlclient.21.dylib
  Referenced from: /Users/gengli/code/venv/lib/python3.6/site-packages/MySQLdb/_mysql.cpython-36m-darwin.so
  Reason: image not found

 

解决办法:

使用pymysql 代替 mysqlclient

 

 

你可能感兴趣的:(Python,sql,数据库)