OS X系统下编译命令因冒号出现执行异常问题求助
Hey there! Let's break down why that gcc command is throwing an error on your old laptop. The message gcc: error: :: No such file or directory is a clear clue that there's a messed-up argument in your gcc call.
The Root Cause
Looking at your gcc command, this segment is the problem:
-I/usr/local/opt/openblas/include:-I/usr/local/opt/openjdk/include :
There are two critical issues here:
- You’re using a colon (
:) to chain two-Iinclude paths directly after one-Iprefix. GCC doesn’t recognize this syntax—each include path needs its own-Iflag, or if using an environment variable likeCPATH, paths are colon-separated without the-Iprefixes. - There’s an extra space followed by a colon (
:) at the end of that line. GCC interprets this standalone::(from the colon in the path chain plus the extra colon) as a filename it’s supposed to compile, which obviously doesn’t exist.
Since you said this worked before, this is almost certainly a misconfigured environment variable (like CFLAGS, CPPFLAGS, or CPATH)—likely from a recent shell config change, conda/pipx environment tweak, or system update that messed up path formatting.
Step-by-Step Fixes
Let’s walk through how to resolve this:
Check your environment variables
Open your terminal and run these commands to spot broken formatting:echo $CFLAGS echo $CPPFLAGS echo $CPATHLook for lines with paths chained like
-I...:-I...or trailing colons/spaces.Temporarily fix variables for the current session
If you find the problematic variable (say,CPATH), reset it with properly formatted paths:export CPATH="/usr/local/opt/openblas/include:/usr/local/opt/openjdk/include"For
CFLAGS, use separate-Iflags with spaces:export CFLAGS="-I/usr/local/opt/openblas/include -I/usr/local/opt/openjdk/include"Then try your pip command again.
Override variables directly in the pip install
If you don’t want to adjust session-wide variables, pass corrected flags directly when installing the library:CFLAGS="-I/usr/local/opt/openblas/include -I/usr/local/opt/openjdk/include" pip install psutilFix permanent config files
Check your shell configs (like~/.bashrc,~/.zshrc, or~/.bash_profile) and conda environment scripts for lines setting these variables incorrectly. Correct the formatting to either:- Colon-separated paths without
-IforCPATH/CPPFLAGS - Space-separated
-I/pathentries forCFLAGS
- Colon-separated paths without
Verify the fix manually
To confirm, adjust the broken segment in your original gcc command and run it directly. Change:-I/usr/local/opt/openblas/include:-I/usr/local/opt/openjdk/include :to:
-I/usr/local/opt/openblas/include -I/usr/local/opt/openjdk/includeIf this runs without errors, you’ve confirmed the issue is fixed.
内容的提问来源于stack exchange,提问作者downer

