Найти - Пользователи
Полная версия: twistd и import
Начало » Web » twistd и import
1
Юрчек
код файла test.py

# -*- coding: utf-8 -*-

from twisted.application import service
import mylib.cfg

application = service.Application("test")
Запускаю командой
$ twistd -ny test.py
и получаю ошибку импорта mylib.cfg.
Дерево каталогов
./test.py
./mylib/cfg.py
./mylib/__init__.py
Можно ли без манипуляций с sys.path добиться импорта?
o7412369815963
да, текст ошибки приведите
Юрчек
(python_env)root@dev2:/opt/hlpbx# twistd -ny test.py

Unhandled Error
Traceback (most recent call last):
File "/opt/hlpbx/python_env/lib/python2.6/site-packages/twisted/application/app.py", line 622, in run
runApp(config)
File "/opt/hlpbx/python_env/lib/python2.6/site-packages/twisted/scripts/twistd.py", line 23, in runApp
_SomeApplicationRunner(config).run()
File "/opt/hlpbx/python_env/lib/python2.6/site-packages/twisted/application/app.py", line 376, in run
self.application = self.createOrGetApplication()
File "/opt/hlpbx/python_env/lib/python2.6/site-packages/twisted/application/app.py", line 441, in createOrGetApplication
application = getApplication(self.config, passphrase)
--- <exception caught here> ---
File "/opt/hlpbx/python_env/lib/python2.6/site-packages/twisted/application/app.py", line 452, in getApplication
application = service.loadApplication(filename, style, passphrase)
File "/opt/hlpbx/python_env/lib/python2.6/site-packages/twisted/application/service.py", line 400, in loadApplication
application = sob.loadValueFromFile(filename, 'application', passphrase)
File "/opt/hlpbx/python_env/lib/python2.6/site-packages/twisted/persisted/sob.py", line 210, in loadValueFromFile
exec fileObj in d, d
File "test.py", line 4, in <module>
import mylib.cfg
exceptions.ImportError: No module named mylib.cfg

Failed to load application: No module named mylib.cfg
o7412369815963
походу запуск с другой папки происходит, попробуйте перед импортом перейти в нужную папку os.chdir
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB