简体   繁体   中英

Compiling Python3 Project on Macbook. 'stdio.h' file not found error

I was trying to compile Python3 locust tests using bazel but was getting an error during compile. This was the main part of the error:

 Compiling with an SDK that doesn't seem to exist: /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk
    Please check your Xcode installation
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -g0 -Iext -I/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c ext/_parser.c -o build/temp.macosx-11-x86_64-3.9/ext/_parser.o
    clang: warning: no such sysroot directory: '/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk' [-Wmissing-sysroot]
    In file included from ext/_parser.c:2:
    /usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9/Python.h:25:10: fatal error: 'stdio.h' file not found
    #include <stdio.h>

I'm compiling on a Macbook Pro (Intel) on Big Sur version 11.6.7.

My solution feels super hacky, and I'll accept another answer if there's a more canonical solution. However, this seems to unblock me.

...

The error noted that the folder /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk was missing. I checked the folder and found that it was indeed missing.

✗ ls /Library/Developer/CommandLineTools/SDKs/
MacOSX.sdk      MacOSX10.15.sdk MacOSX11.1.sdk

I did, however, see that the folder MacOSX11.1.sdk existed. So I made a symbolic link to that folder with the name requested in my build...

cd /Library/Developer/CommandLineTools/SDKs/
sudo ln -s MacOSX11.1.sdk MacOSX11.sdk

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM