我有一个独立的外部应用程序,它带有自己的python子集和依赖项。我打算将此程序包与我自己的python代码结合在一起,并在Google Cloud Dataflow上运行。我已经准备好管道。我需要运行给出错误“找不到”的shell脚本的帮助,
/usr/local/lib/python2.7/dist-packages/<package>/bin/python2.7: not found
我使用
从我的python代码中调用脚本Process = '/usr/local/lib/python2.7/dist-packages/<package>/bin/Process'
subprocess.check_call([Process , str(filepath)])
处理的内容是:
#!/bin/sh
. /usr/local/lib/python2.7/dist-packages/<package>/Bashrc
/usr/local/lib/python2.7/dist-packages/<package>/bin/python2.7 -s /usr/local/lib/python2.7/dist-packages/<package>/lib/python2.7/site-packages/<package_name>/Process.py "$@"
我尝试将支票放入我的python代码中
if os.path.exists("/usr/local/lib/python2.7/dist-packages/<package>/bin/Process"):
logging.info("Process exists")
else:
logging.info("Process does not exists")
if os.path.exists("/usr/local/lib/python2.7/dist-packages/<package>/bin/python2.7"):
logging.info("/usr/local/lib/python2.7/dist-packages/<package>/bin/python2.7 exists")
else:
logging.info("/usr/local/lib/python2.7/dist-packages/<package>/bin/python2.7 does not exist")
if os.path.exists("/usr/local/lib/python2.7/dist-packages/<package>/Bashrc"):
logging.info("/usr/local/lib/python2.7/dist-packages/<package>/Bashrc exists")
else:
logging.info("/usr/local/lib/python2.7/dist-packages/<package>/Bashrc does not exist")
所有人都确认该文件存在。如果我在系统上执行<package>/bin/python2.7
,它将完美启动IDLE。
此问题与问题here非常相关。我还编辑了PYTHONPATH,PATH和其他环境变量,使其包含/usr/local/lib/python2.7/dist-packages/<package>/bin/
我希望子集python二进制文件可以运行并开始使用所有输入参数执行Process.py。我该怎么办?
基本上我想将变量filepath
作为函数的参数传递给Process。