除非我使用sudo运行,否则python无法找到flatc编译器

时间:2019-03-19 20:34:21

标签: python-3.x flatbuffers

我已经在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()

0 个答案:

没有答案