码迷,mamicode.com
首页 > 数据库 > 详细

mac 解决mysqlclient安装失败问题

时间:2020-06-07 16:34:26      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:failed   sql   except   var   tor   fail   file   status   config   

环境 mac
本人下载mysql 是采用brew 下载,所以安装路径在/usr/local/Cellar/mysql/8.0.19_1/

brew install mysql
brew install mysql-connector-c
sudo sed -i -e ‘s/libs="$libs -l "/libs="$libs -lmysqlclient -lssl -lcrypto"/g‘ /usr/local/mysql/bin/mysql_config
下载mysql-client
brew install mysql-client
路径在:/usr/local/Cellar/mysql-client/8.0.19/

采用Django启动项目报错
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.

Did you install mysqlclient?

下载mysqlclient
pip install mysqlclient
下载时报错
报错 1:
_mysql.c:29:10: fatal error: ‘my_config.h‘ file not found

#include "my_config.h"

         ^~~~~~~~~~~~~

1 error generated.

error: command ‘/usr/bin/clang‘ failed with exit status 1

解决办法:
export DYLD_LIBRARY_PATH="/usr/local/Cellar/mysql/8.0.19_1/lib"
本人是采用brew 下载mysql 的,所以。存储路径是/usr/local/Cellar/mysql/8.0.19_1/ 。

报错2
File "/private/var/folders/wy/4v8w8ht90m7_1xzxklx1tnsm0000gn/T/pip-install-bbm57hwr/mysqlclient/setup_posix.py", line 47, in get_config

    libs = mysql_config("libs_r")

  File "/private/var/folders/wy/4v8w8ht90m7_1xzxklx1tnsm0000gn/T/pip-install-bbm57hwr/mysqlclient/setup_posix.py", line 29, in mysql_config

    raise EnvironmentError("%s not found" % (mysql_config.path,))

OSError: mysql_config not found

----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
解决办法:
export PATH=$PATH:/usr/local/Cellar/mysql/8.0.s19_1/bin

报错3:
ld: library not found for -lssl

clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: command ‘/usr/bin/clang‘ failed with exit status 1

解决办法:
export PATH="/usr/local/Cellar/mysql-client/8.0.19/bin:$PATH"
至此下载成功。

mac 解决mysqlclient安装失败问题

标签:failed   sql   except   var   tor   fail   file   status   config   

原文地址:https://www.cnblogs.com/heych/p/13060945.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!