我已经在flatc
中安装了Flatbuffers编译器/usr/local/bin/flatc
。
$ which flatc
/usr/local/bin/flatc
但是,如果我运行一个需要flatc
而没有sudo
的python程序,它将找不到它。
但是如果我使用sudo运行它,它可以找到它。我的usr/local/bin
上有$PYTHONPATH
我尝试了很多事情,但似乎无法使其正常工作。
这是代码:
import os
this_files_location = os.path.dirname(os.path.abspath(__file__))
cmd = "flatc --python -o "+this_files_location+"/ " +\
this_files_location+"/schema.fbs"
print("Executing {}".format(cmd))
ret = os.system(cmd)
if ret != 0:
print("Warning: Flatbuffers not installed.")
print("Please take the latest release from: " +
"https://github.com/google/flatbuffers/releases and " +
"ensure it is installed")
quit()