【发布时间】:2017-08-19 04:34:51
【问题描述】:
我尝试使用 plist 脚本来启动我的 python 程序但徒劳无功,在程序中,我导入了一个包 tushare,但是在日志文件“stderr”中返回了“ImportError: No module named tushare”,这个包可以成功导入用anaconda编写的python程序。
结果:
Traceback (most recent call last):
File "/Users/jacksonshawn/PythonCodes/apple.py", line 8, in <module>
import tushare as ts
ImportError: No module named tushare
猜想可能是由于 plist 脚本中缺少“EnvironmentVariables”参数,但我不知道如何修改 plist 脚本来解决问题。每次,我都会执行以下操作来执行脚本。语法检查plist脚本,可以执行。
"launchctl unload -w com.tushare.refreshall.plist"
"launchctl load -w com.tushare.refreshall.plist"
"launchctl start com.tushare.refreshall.plist"
【问题讨论】:
-
任何人都可以帮忙吗?真的很感激。这个模块tushare在anaconda中的python 2.7中运行良好,我只是不知道为什么它不能导入需要由launchctl脚本触发的程序中.也许我的 plist 脚本中缺少像“EnvironmentVariables”这样的参数。
-
向您的代码添加一些调试以打印 sys.path 的值。确保您要导入的模块在 sys.path 上。
-
尝试在python2上创建一个虚拟环境,做项目。并尝试在该环境中安装 tushare。
标签: python macos info.plist launchctl root.plist