The following error occurred when installing the Twisted library using pip:
In file included from /usr/local/lib/gcc/x86_64-apple-darwin15.6.0/7.1.0/include-fixed/syslimits.h:7:0,
from /usr/local/lib/gcc/x86_64-apple-darwin15.6.0/7.1.0/include-fixed/limits.h:34,
from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:19,
from src/twisted/test/raiser.c:4:
/usr/local/lib/gcc/x86_64-apple-darwin15.6.0/7.1.0/include-fixed/limits.h:194:15: fatal error: limits.h: No such file or directory
#include_next <limits.h> /* recurse down to the real one */
^~~~~~~~~~
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1
After searching the Internet for a long time, I only found a solution for linux. No one mentioned macOS.
After some research, it was found that the update of macOS mojave deliberately deleted /user/include
. So I wondered whether pip can't find limit.h because /usr/include
doesn't exist anymore.
So I executed the following command to manually restore the /usr/include
folder again.
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
You can see that the /usr/include folder has been restored.
Execute after this
pip install Twisted
The result shows successfully installed:
Collecting twisted
Using cached https://files.pythonhosted.org/packages/5d/0e/a72d85a55761c2c3ff1cb968143a2fd5f360220779ed90e0fadf4106d4f2/Twisted-18.9.0.tar.bz2
Requirement already satisfied: zope.interface>=4.4.2 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from twisted) (4.6.0)
Requirement already satisfied: constantly>=15.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from twisted) (15.1.0)
Requirement already satisfied: incremental>=16.10.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from twisted) (17.5.0)
Requirement already satisfied: Automat>=0.3.0 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from twisted) (0.7.0)
Requirement already satisfied: hyperlink>=17.1.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from twisted) (18.0.0)
Requirement already satisfied: PyHamcrest>=1.9.0 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from twisted) (1.9.0)
Requirement already satisfied: attrs>=17.4.0 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from twisted) (18.2.0)
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from zope.interface>=4.4.2->twisted) (39.0.1)
Requirement already satisfied: six in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from Automat>=0.3.0->twisted) (1.11.0)
Requirement already satisfied: idna>=2.5 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from hyperlink>=17.1.1->twisted) (2.7)
Building wheels for collected packages: twisted
Running setup.py bdist_wheel for twisted ... done
Stored in directory: /Users/Mescetina/Library/Caches/pip/wheels/57/2e/89/11ba83bc08ac30a5e3a6005f0310c78d231b96a270def88ca0
Successfully built twisted
Apple's macOS 10.14 update removed /usr/include
, which caused pip to find the header file and prevented the installation of the Twisted library. I hope my solution can help you all.