标签:error status python3 解压 文件 config matching evel alt
MySQLdb 是用于Python链接Mysql数据库的接口
安装MySQLdb可以用终端命令
pip3 install MySQLdb-python
但是出现报错,错误原因为
:mysql_config not found
这是因为在配置文件中,找不到mysql配置文件导致,也就是 mysql_config
解决办法:
手动下载MySQLdb文件包,下载链接:https://pypi.org/project/MySQL-python/#files
解压之后找到配置文件"site.cfg",找到
#mysql_config = /usr/local/bin/mysql_config
去掉注释#,并修改为安装的mysql配置文件的正确路径
mysql_config = /usr/local/mysql/bin/mysql_config
然后在终端中,先进入刚才查找site.cfg所在的文件夹
运行安装命令
sudo python3 setup.py install
然后就是又一个报错
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun error: command ‘gcc‘ failed with exit status 1
找到这个文件夹Developer,发现里面几乎没啥东西,后来知道mac在重装系统后会删除xcode,需要重新安装
xcode-select --install
安装成功之后在运行MySQLdb的安装命令
sudo python3 setup.py install
还是报错,要疯了
sudo easy_install mysql-python Password: Searching for mysql-python Reading http://pypi.python.org/simple/mysql-python/ Reading http://sourceforge.net/projects/mysql-python/ Reading http://sourceforge.net/projects/mysql-python Best match: MySQL-python 1.2.3 Downloading http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz#md5=215eddb6d853f6f4be5b4afc4154292f Processing MySQL-python-1.2.3.tar.gz Running MySQL-python-1.2.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-UoZlf7/MySQL-python-1.2.3/egg-dist-tmp-phaQqE warning: no files found matching ‘MANIFEST‘ warning: no files found matching ‘ChangeLog‘ warning: no files found matching ‘GPL‘ clang: warning: argument unused during compilation: ‘-mno-fused-madd‘ _mysql.c:36:10: fatal error: ‘my_config.h‘ file not found #include "my_config.h" ^ 1 error generated. error: Setup script exited with error: command ‘clang‘ failed with exit status 1 ninjaiimac:MySQL-python-1.2.3 sunninjaisun$
遍寻不到方法,最后还是stackoverflow上的大神
brew install mysql brew unlink mysql brew install mysql-connector-c sed -i -e ‘s/libs="$libs -l "/libs="$libs -lmysqlclient -lssl -lcrypto"/g‘ /usr/local/bin/mysql_config pip install MySQL-python brew unlink mysql-connector-c brew link --overwrite mysql
一顿操作猛如虎,然后继续原来的安装命令
其实还不行,但是就这几条命令,根据提示试一两次也就成功了,虽然还有格式错误,但已经不妨碍了。
在pycharm中MySQLdb下面终于没有红色波浪线了。
标签:error status python3 解压 文件 config matching evel alt
原文地址:https://www.cnblogs.com/pybxs/p/11687338.html