[英]command 'cc' failed with exit status 1 on OSX High Sierra
我正试图在Mac Os高山上运行
pip install MySQL-python
但我得到了
error: command 'cc' failed with exit status 1
我已经尝试过关于这个主题的解决方案,但它没有用。
这是完整的错误消息
The directory '/Users/filipeferminiano/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/filipeferminiano/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting MySQL-python
Downloading https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
100% |████████████████████████████████| 112kB 289kB/s
Installing collected packages: MySQL-python
Running setup.py install for MySQL-python ... error
Complete output from command /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-install-8I1X5u/MySQL-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/tmp/pip-record-z5HohX/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.13-intel-2.7
copying _mysql_exceptions.py -> build/lib.macosx-10.13-intel-2.7
creating build/lib.macosx-10.13-intel-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb
creating build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.13-intel-2.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.13-intel-2.7
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mysql/8.0.11/include/mysql -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.13-intel-2.7/_mysql.o
_mysql.c:44:10: fatal error: 'my_config.h' file not found
#include "my_config.h"
^~~~~~~~~~~~~
1 error generated.
error: command 'cc' failed with exit status 1
----------------------------------------
Command "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-install-8I1X5u/MySQL-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/tmp/pip-record-z5HohX/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-install-8I1X5u/MySQL-python/
这是python
which python
/usr/bin/python
这就是我正在使用的点子
which pip
/usr/local/bin/pip
首先,你确定要使用MySQL-python吗? 这是一个在过去五年中为遗留支持进行半维护的大部分死亡项目,甚至不适用于当前版本的MySQL。 它想要5.0或5.1; 当前版本是8.0,甚至当前的旧版本是5.7。
其他选择包括:
mysql-connector
,又名MySQLConnector / Python:这是MySQL / Oracle官方支持的库。 它可能有点慢,这对大多数项目来说无关紧要,但有时也可以。 它也有一个不同的API(虽然如果你坚持使用DB-API 2方法,唯一的区别是连接调用;除此之外它应该只是低级别的东西,这是不同的)。 mysqlclient
:这是Django和其他一些框架使用的包。 它是MySQL-Python
的一个更新的分支(有一些东西来自其废弃的继任者, moist
)。 它甚至可以配置为将自己安装为MySQLdb
,与MySQL-python
使用的名称相同。 PyMySQL
:第三方软件包,与旧的MySQL-python
尽可能兼容,但更简单,更易于维护和安装。 cmysql
,一个叉PyMySQL
只是稍微难以安装的,但应该比它,或快于mysql-connector
。 一些Linux发行版 - 包括IIRC,Ubuntu的最新版本 - 提供了一个名为python-MySQLdb
的软件包或类似的实际上不是MySQL-python的软件包,而是使用install-as-MySQLdb选项构建的mysqlclient
。 因此,如果您尝试使用MySQL-python
的唯一原因是它是您在某些Ubuntu盒子上使用的,那么它可能不是您使用的,因此不是您想要的。
其中一些替代方案还需要MySQL(特别是MySQLConnector/C
,也称为libmysqlclient
及其开发库),有些则不需要 - 但它们都与当前版本兼容。 (尽管在PyMySQL和cmysql的文档中有一些关于8.0加密更改的注释,但如果使用8.0,则可能需要阅读。)
无论如何,如果你真的想要MySQL-python,那么你需要在5.x版本中安装MySQL。 INSTALL
指向MySQL下载 。
如果你想要5.0或5.1,你将需要浏览其中一个镜像的Downloads
文件夹以找到源包并按照说明构建和安装它,因为没有可用于当前Mac的二进制安装程序。
如果你想要更高版本的5.x版本 - 记住,MySQL-python不支持它们,但是它们可能有用 - Oracle仍然为那些提供Mac二进制安装程序。 如果在主下载部分找不到它们,则镜像的“下载”文件夹将包含它们。 截至目前,5.6和5.7具有以-macos10.13-x86_64.dmg
结尾的二进制安装程序包。
但是,您可能更乐意使用Homebrew安装它。 按照该页面上的说明安装brew
,然后将其用于:
brew install mysql@5.5
MySQL-python 还需要OpenSSL库,而Apple故意隐藏操作系统使用的那些库,以防止人们意外地针对旧版本构建代码而不获取安全更新。 较新的库应该都知道如何处理这个,但MySQL-python没有。 安装可用OpenSSL的最简单方法是再次使用Homebrew:
brew install openssl
但是,不要只运行该命令并关闭窗口。 阅读输出,因为如果你想构建MySQL-python,你必须完成它所说的所有内容。
阿巴梅特的回答对我不起作用。 虽然这样做,但您可以尝试跳过第一步,
brew install mysql-connector-c
brew install mysql
brew link --overwrite mysql
pip install MySQL-python
我的问题是我使用的是MySql版本8.0.12。 一旦我降级到MySQL 5.7,它就完美安装了。 我使用以下内容删除版本8: https : //gist.github.com/vitorbritto/0555879fe4414d18569d
上述要点是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.