[英]command 'cc' failed with exit status 1 on OSX High Sierra
I'm trying to run on Mac Os high Sierra 我正试图在Mac Os高山上运行
pip install MySQL-python
But I'm getting 但我得到了
error: command 'cc' failed with exit status 1
I already tried the solution on this topic , but it didn't work. 我已经尝试过关于这个主题的解决方案,但它没有用。
This is the full error message 这是完整的错误消息
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/
This is the python 这是python
which python
/usr/bin/python
and this is the pip I'm using 这就是我正在使用的点子
which pip
/usr/local/bin/pip
First, are you sure you want to use MySQL-python ? 首先,你确定要使用MySQL-python吗? This is a mostly-dead project that's been semi-maintained for legacy support for the past half decade, and doesn't even work with current versions of MySQL. 这是一个在过去五年中为遗留支持进行半维护的大部分死亡项目,甚至不适用于当前版本的MySQL。 It wants 5.0 or maybe 5.1; 它想要5.0或5.1; the current version is 8.0, and even the current legacy version is 5.7. 当前版本是8.0,甚至当前的旧版本是5.7。
Other options include: 其他选择包括:
mysql-connector
, aka MySQLConnector/Python: This is the officially supported library, from MySQL/Oracle. mysql-connector
,又名MySQLConnector / Python:这是MySQL / Oracle官方支持的库。 It can be a bit slow, which doesn't matter for most projects, but it can sometimes. 它可能有点慢,这对大多数项目来说无关紧要,但有时也可以。 It also has a different API (although if you stick to DB-API 2 methods, the only difference is the connect call; beyond that it should just be low-level stuff that's different). 它也有一个不同的API(虽然如果你坚持使用DB-API 2方法,唯一的区别是连接调用;除此之外它应该只是低级别的东西,这是不同的)。 mysqlclient
: This is the package that Django and some other frameworks use. mysqlclient
:这是Django和其他一些框架使用的包。 It's an updated fork of MySQL-Python
(with a few things from its abandoned successor, moist
). 它是MySQL-Python
的一个更新的分支(有一些东西来自其废弃的继任者, moist
)。 It can even be configured to install itself as MySQLdb
, the same name used by MySQL-python
. 它甚至可以配置为将自己安装为MySQLdb
,与MySQL-python
使用的名称相同。 PyMySQL
: A third-party package built to be as compatible as possible with the old MySQL-python
but simpler and easier to maintain, and install. PyMySQL
:第三方软件包,与旧的MySQL-python
尽可能兼容,但更简单,更易于维护和安装。 cmysql
, a fork of PyMySQL
that's only slightly harder to install, but should be faster than it, or than mysql-connector
. cmysql
,一个叉PyMySQL
只是稍微难以安装的,但应该比它,或快于mysql-connector
。 Some linux distros—including, IIRC, recent versions of Ubuntu—provide a package named python-MySQLdb
or similar that is not actually MySQL-python, but instead mysqlclient
built with the install-as-MySQLdb option. 一些Linux发行版 - 包括IIRC,Ubuntu的最新版本 - 提供了一个名为python-MySQLdb
的软件包或类似的实际上不是MySQL-python的软件包,而是使用install-as-MySQLdb选项构建的mysqlclient
。 So, if the only reason that you're trying to use MySQL-python
is that it's what you were using on some Ubuntu box, it's probably not what you were using, and therefore not what you want. 因此,如果您尝试使用MySQL-python
的唯一原因是它是您在某些Ubuntu盒子上使用的,那么它可能不是您使用的,因此不是您想要的。
Some of these alternative also require MySQL (specifically, MySQLConnector/C
, aka libmysqlclient
, and its development libraries), some don't—but they're all compatible with current versions. 其中一些替代方案还需要MySQL(特别是MySQLConnector/C
,也称为libmysqlclient
及其开发库),有些则不需要 - 但它们都与当前版本兼容。 (Although there are some notes on 8.0 crypto changes in the docs for PyMySQL and cmysql, which you might want to read if you use 8.0.) (尽管在PyMySQL和cmysql的文档中有一些关于8.0加密更改的注释,但如果使用8.0,则可能需要阅读。)
Anyway, if you really want MySQL-python, then you will need to install MySQL in a 5.x version. 无论如何,如果你真的想要MySQL-python,那么你需要在5.x版本中安装MySQL。 The INSTALL
points you to MySQL downloads . INSTALL
指向MySQL下载 。
If you want 5.0 or 5.1, you will have to dig through the Downloads
folder at one of the mirrors to find a source package and follow the instructions to build and install it, since there are no binary installers that work on current Macs. 如果你想要5.0或5.1,你将需要浏览其中一个镜像的Downloads
文件夹以找到源包并按照说明构建和安装它,因为没有可用于当前Mac的二进制安装程序。
If you want later 5.x versions—which, remember, are not supported by MySQL-python, but they might work—Oracle is still providing Mac binary installers for those. 如果你想要更高版本的5.x版本 - 记住,MySQL-python不支持它们,但是它们可能有用 - Oracle仍然为那些提供Mac二进制安装程序。 If you can't find them in the main downloads section, the mirrors' Downloads folder will have them. 如果在主下载部分找不到它们,则镜像的“下载”文件夹将包含它们。 As of right now, 5.6 and 5.7 have binary installer packages that end with -macos10.13-x86_64.dmg
. 截至目前,5.6和5.7具有以-macos10.13-x86_64.dmg
结尾的二进制安装程序包。
However, you might be happier installing it with Homebrew . 但是,您可能更乐意使用Homebrew安装它。 Follow the instructions on that page to install brew
, then to use it to: 按照该页面上的说明安装brew
,然后将其用于:
brew install mysql@5.5
MySQL-python also requires OpenSSL libraries, and Apple deliberately hides the ones used by the OS to prevent people from accidentally building code against an old version and not getting security updates. MySQL-python 还需要OpenSSL库,而Apple故意隐藏操作系统使用的那些库,以防止人们意外地针对旧版本构建代码而不获取安全更新。 The newer libraries should all know how to handle this, but MySQL-python does not. 较新的库应该都知道如何处理这个,但MySQL-python没有。 The easiest way to install a usable OpenSSL is with Homebrew again: 安装可用OpenSSL的最简单方法是再次使用Homebrew:
brew install openssl
But don't just run that command and close the window. 但是,不要只运行该命令并关闭窗口。 Read the output, because you have to do all the stuff it says if you want MySQL-python to build. 阅读输出,因为如果你想构建MySQL-python,你必须完成它所说的所有内容。
abamert's answer did not work for me. 阿巴梅特的回答对我不起作用。 Though this did, you might try skipping the first step, 虽然这样做,但您可以尝试跳过第一步,
brew install mysql-connector-c
brew install mysql
brew link --overwrite mysql
pip install MySQL-python
My issue was that I was using MySql Version 8.0.12. 我的问题是我使用的是MySql版本8.0.12。 As soon as I downgraded to MySQL 5.7, it was installed perfectly. 一旦我降级到MySQL 5.7,它就完美安装了。 I used the following to delete the version 8 by following: https://gist.github.com/vitorbritto/0555879fe4414d18569d 我使用以下内容删除版本8: https : //gist.github.com/vitorbritto/0555879fe4414d18569d
The gist of the above was: 上述要点是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.