我已经创建了一个应该作为服务运行的python软件。它有一个模块和一个脚本,位于/etc/init.d下。我用distutils来打包系统。一切都安装得很好,但是当我试图从/etc/init.d运行脚本时,会引发以下异常:Traceback (most recent call last):
File "/etc/init.d/printserver.py", line 11, in
from myprintserver import *
File "/etc/rc.d/init.d/printserver.py", line 12, in
import myprintserver.printserver
ImportError: No module named printserver
当我试图通过命令行导入模块时,它工作得很好。在
^{pr2}$
我检查了模块下所有的东西。我印刷的系统路径在错误出现之前,并包含/usr/lib/python2.7/site-packages。系统路径打印如下:['/etc/rc.d/init.d', '/usr/lib/python2.7/site-packages/escpos-1.0-py2.7.egg', '/usr/lib/python2.7/site-packages/pyusb-1.0.0a3-py2.7.egg', '/usr/lib/python2.7/site-packages/mechanize-0.2.5-py2.7.egg', '/usr/lib/python2.7/site-packages/PIL-1.1.7-py2.7-linux-x86_64.egg', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/gst-0.10', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']