error: command ‘gcc’ failed with exit status 1 [How to Solve]

To install MySQL Python under MacOS, execute the following statement:

sudo pip install MySQL-Python

The following error message was encountered:

/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

We can see that GCC lacks the header file limit. H. We can see that a person on Google encountered the same problem. He updated the new version of GCC and the problem was solved

The solution is: Update GCC

1. Download macport for your system at https://www.macports.org/install.php

My system is MacOS Mojave, so I downloaded and installed MacOS Mojave v10.14

2. Update the macport version and make sure it is the latest version. At the command line, enter:

sudo port selfupdate

3. To install GCC, enter:

sudo port install gcc7

Then wait for the installation, the process may be slow. I installed gcc7. If you want to install any other version, such as version x, you can enter gccx

There is a problem when executing this statement:

Warning: xcodebuild exists but failed to execute

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

The reason is that after the version before Xcode 4.3 is updated, Xcode select still points to the old version of Xcode. You need to enter the following on the command line:

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

This method is my reference link https://trac.macports.org/wiki/ProblemHotlist , finish, and then sudo port install gcc7

4. I updated the latest version of gcc7 with the following command. Of course, you can skip this step

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, after the installation is complete, type gcc -version to check the current version, I found that it is still the old version 4.8.5, not the new version 7 that I installed.

(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.

This is because the original default version is 4.8.5 and you need to switch versions.

Switching versions: You can view all versions of MacPort Administration with the following statement. The versions that start with the prefix mp are the versions managed by MacPort itself, while gcc7 and IIvm-gcc7 are managed by Xcode.

port select --list gcc

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

Available versions for gcc:

mp-gcc7

none (active)

You can see that I installed the new version of mp-gcc7

Set it as the default.

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.

REVIEW.

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.

You can see that it is now gcc7.4.0.

Similar Posts: