问题
CentOS7 使用 pip 安装 SCons,默认安装位置是 /usr/local/bin/scons, 库(engine)的默认安装位置是 /usr/local/lib/python3.6/site-packages/scons,但在运行时默认的搜索 engine 的路径不包含安装路径,导致错误。
$ scons SCons import failed. Unable to find engine files in: /usr/local/lib/scons-3.1.2 /usr/lib/scons-3.1.2 /usr/local/lib/scons-3.1.2 /usr/lib/python2.7/site-packages/scons-3.1.2 /usr/lib64/scons-3.1.2 /usr/local/lib/scons /usr/lib/scons /usr/local/lib/scons /usr/lib/python2.7/site-packages/scons /usr/lib64/scons Traceback (most recent call last): File "/usr/local/bin/scons", line 195, in <module> import SCons.Script ImportError: No module named SCons.Script
解决方法
如下建立软链接,
$ sudo ln -fs /usr/local/lib/python3.6/site-packages/scons /usr/local/lib/scons
即可正常使用,
$ scons scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... gcc -o hello.o -c hello.c gcc -o hello hello.o scons: done building targets.
……