MacOS下想安装MySQL-Python,执行语句:

sudo pip install MySQL-Python

遇到了如下错误信息:

/Users/kaitlyn/anaconda3/envs/env2.7/lib/gcc/x86_64-apple-darwin11.4.2/4.8.5/include-fixed/limits.h:168:61: fatal error: limits.h: No such file or directory

#include_next <limits.h>  /* recurse down to the real one */

^

compilation terminated.

error: command 'gcc' failed with exit status 1

可以看到gcc缺少头文件limit.h,google上看到有一个人遇到了相同的问题,他更新了新版本的gcc,问题得以解决。

解决方案是:更新gcc

1、下载适用于你的系统的MacPort,地址为https://www.macports.org/install.php

  我的系统是macOS Mojave,所以下载安装了macOS Mojave v10.14

2、更新MacPort版本,确保是最新版,在命令行输入:

sudo port selfupdate

3、安装gcc,在命令行输入:

sudo port install gcc7

  然后等待安装,过程可能比较慢。我安装的是gcc7,如果想安装任意别的版本,比如版本x,可以输入gccx。

  在执行这条语句时这里遇到一个问题:

  Warning: xcodebuild exists but failed to execute

  Warning: Xcode does not appear to be installed; most ports will likely fail to build.

  

  原因是从xcode4.3之前的版本更新之后,xcode-select依然指向旧版的xcode,需要在命令行输入:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

  这个办法我是参考的链接https://trac.macports.org/wiki/ProblemHotlist,finish这条命令以后再sudo port install gcc7安装一下。

4、我使用下面的命令更新了gcc7的最新版,当然这一步你也可以跳过

sudo port -n upgrade --force gcc7

(env2.7) Kaitlyns-Mac:lib kaitlyn$ sudo port -n upgrade --force gcc7

--->  Fetching archive for gcc7

--->  Attempting to fetch gcc7-7.4.0_0.darwin_18.x86_64.tbz2 from https://pek.cn.packages.macports.org/macports/packages/gcc7

--->  Attempting to fetch gcc7-7.4.0_0.darwin_18.x86_64.tbz2.rmd160 from https://pek.cn.packages.macports.org/macports/packages/gcc7

--->  Computing dependencies for gcc7

--->  Deactivating gcc7 @7.4.0_0

--->  Cleaning gcc7

--->  Uninstalling gcc7 @7.4.0_0

--->  Cleaning gcc7

--->  Computing dependencies for gcc7

--->  Installing gcc7 @7.4.0_0

--->  Activating gcc7 @7.4.0_0

--->  Cleaning gcc7

--->  Scanning binaries for linking errors

--->  No broken files found.

--->  No broken ports found.

5、安装完成以后,输入gcc -version查看现在的版本,发现依然是以前的旧版本4.8.5,而不是我安装的新版本7。

(env2.7) Kaitlyns-Mac:lib kaitlyn$ gcc --version

gcc (GCC) 4.8.5

Copyright (C) 2015 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  这是因为原始默认版本就是4.8.5,需要切换版本。

  切换版本:你可以下面的语句查看MacPort管理所有版本。以mp作为前缀开头的是MacPort自己管理的版本,而gcc7和IIvm-gcc7是Xcode管理的。

port select --list gcc

(env2.7) Kaitlyns-Mac:bin kaitlyn$ port select --list gcc

Available versions for gcc:

mp-gcc7

none (active)

  可以看见我安装新版mp-gcc7

设置它为默认:

sudo port select --set gcc mp-gcc7

(env2.7) Kaitlyns-Mac:bin kaitlyn$ sudo port select --set gcc mp-gcc7

Password:

Selecting 'mp-gcc7' for 'gcc' succeeded. 'mp-gcc7' is now active.

再查看:

gcc --version

(env2.7) Kaitlyns-Mac:bin kaitlyn$ gcc --version

gcc (MacPorts gcc7 7.4.0_0) 7.4.0

Copyright (C) 2017 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

可以看到现在为gcc7.4.0了。

error: command 'gcc' failed with exit status 1的更多相关文章

  1. pip error: command 'gcc' failed with exit status 1

    SWIG/_m2crypto_wrap.c:127:20: 致命错误:Python.h:没有那个文件或目录     #include <Python.h>                  ...

  2. Centos4.3安装MySQL-python-1.2.3,出现error: command 'gcc' failed with exit status 1

    在Linux Centos 4.3上安装MySQL-python-1.2.3的时候出现error: command 'gcc' failed with exit status 1, 具体原因是因为没有 ...

  3. mysql_config not found和error: command 'gcc' failed with exit status 1

    要想使python可以操作mysql 就需要MySQL-python驱动,它是python 操作mysql必不可少的模块. 下载地址:https://pypi.python.org/pypi/MySQ ...

  4. 【centos】 error: command 'gcc' failed with exit status 1

    原文连接http://blog.csdn.net/fenglifeng1987/article/details/38057193 用安装Python模块出现error: command 'gcc' f ...

  5. centos7 安装mysql--python模块出现EnvironmentError: mysql_config not found和error: command 'gcc' failed with exit status 1

    要想使python可以操作mysql 就需要MySQL-python驱动,它是python 操作mysql必不可少的模块. 下载地址:https://pypi.python.org/pypi/MySQ ...

  6. python安装模块的时候报错error: command 'gcc' failed with exit status 1

    [情况] 在写Python代码的时候,需要用到psutil模块,需要安装. 但是在安装时,报错:error: command 'gcc' failed with exit status 1 [解决步骤 ...

  7. pip安装模块时:error: command 'gcc' failed with exit status 1

    用安装python模块出现error: command 'gcc' failed with exit status 1 问题: gcc编译缺少模块 解决方法: yum install gcc libf ...

  8. python psutil 编译中断。 error: command 'gcc' failed with exit status 1

    error info [root@chenbj psutil-2.0.0]# python setup.py install running install running bdist_egg run ...

  9. pycuda installation error: command 'gcc' failed with exit status 1

    原文:python采坑之路 Setup script exited with error: command 'gcc' failed with exit status 1 伴随出现"cuda ...

随机推荐

  1. JavaScript数组方法--pop、shift、unshift

    其实还有一个方法push,应该放在一起说的,问题是他跟concat跑了,那只剩下这哥仨了. pop:pop()方法从数组中删除最后一个元素,并返回该元素的值.此方法更改数组的长度.捎带一下push,p ...

  2. 微信小程序学习 一

    1. 目录结构 app.js  —— 必须配置Page({})  在新版本中 app.json  —— 注册,路由不用加后缀,是将整个文件里面的四个文件都注册进去,并且做关联,所以在页面中就不需要引用 ...

  3. QTP - 描述性编程

    描述性编程: 1.QTP的描述性编程能够摆脱测试对象库的限制,编写出更为复杂.适应能力更强的测试脚本. 2.即不需要在仓库晨定义,也能访问和操作实际对象. 3.用描述性编程编写的测试脚本在运行时,QT ...

  4. Sublime Text3使用Package Control 报错There Are No Packages Available For Installation

    转 http://blog.csdn.net/feilong_csdn/article/details/67638660 在使用sublime时,有时候我们希望将代码复制出来后仍然是高亮显示,这样我们 ...

  5. DNS的功能-域名空间、域名注册和域名解析

    DNS的主要功能包括以下三个: 域名空间:定义一个包括所有可能出现的主机名字的域名空间. 域名注册:保证每台主机域名的唯一性. 域名解析:提供一种有效的域名与IP地址转换机制. DNS域名空间 (1) ...

  6. Spring事务实现分析

    一.Spring声明式事务用法 1.在spring配置文件中配置事务管理器 <bean id="baseDataSource" class="com.alibaba ...

  7. Docker 容器操作命令

    容器是镜像的一个运行实例,镜像是静态的只读文件,而容器带有运行时需要的可写文件层.如果认为虚拟机是模拟运行的一整套操作系统(包括内核.应用运行态环境和其他系统环境)和跑在上面的应用,那么Docker容 ...

  8. HBASE分布式集群搭建(ubuntu 16.04)

    1.hbase是依赖Hadoop运行的,因此先确保自己已搭建好Hadoop集群环境 没安装的可以参考这里:https://www.cnblogs.com/chaofan-/p/9740408.html ...

  9. Linux一行命令处理批量文件

    前言 最好的方法不一定是你最快能想到的.这里提供一种使用sed命令构造命令解决处理批量文件的技巧,供参考. 需求案例1 将当前目录下所有的0_80_91.txt.0_80_92.txt.0_80_93 ...

  10. redis cluster介绍

    讲解分布式数据存储的核心算法,数据分布的算法 hash算法 -> 一致性hash算法(memcached) -> redis cluster,hash slot算法 一.概述 1.我们的m ...