Python 模块导入错误(在 linux 中工作正常,但在 FreeBSD 中失败)
我们有一个应用程序当前正在 Linux 系统上运行。现在我正在尝试将其移植到 FreeBSD 上。我们正在使用 twistd 运行应用程序
/usr/bin/twistd -y $TACFILE --rundir $RUNDIR --logfile=/dev/null --pidfile=$PIDFILE
我的 tacfile 是一个以这些行开头的 python 文件
#!/opt/python/bin/python
import os
from twisted.application import internet, service
from twisted.internet import reactor
from twisted.enterprise import adbapi
from twisted.plugin import getPlugins
from twisted.python import log
import labris.flyng.iflyng as iflyng
import labris.flyng.config as config
import labris.flyng.plugins as pplugins
import labris.flyng.protocols as flyng_protocols
但我在这一行中收到错误:
import labris.flyng.iflyng as iflyng
错误是:
exceptions.ImportError: No module named labris.flyng.iflyng
Failed to load application: No module named labris.flyng.iflyng
但正如您所理解的,扭曲导入不会导致错误,而labris 导入失败。该应用程序在 Linux 中运行没有任何错误。
如果与它有关的话 /opt/python/bin/python
是一个指向 /usr/local/bin/python2.6
的符号链接
既扭曲又路径下有labris目录 /usr/local/lib/python2.6/site-packages 他们的权限是正确的并且每个人都具有相同的权限。
ls /usr/local/lib/python2.6/site-packages/labris/flyng 的输出是 __init__.py config.py db iflyng.py 解析器插件protocols.py
所以我不认为模块的路径有错误。我不知道这个错误的原因可能是什么。任何线索、指示都是非常受欢迎的。
We have an application which is currently working on a linux system. Now I am trying to port it to FreeBSD. We are running the application using twistd
/usr/bin/twistd -y $TACFILE --rundir $RUNDIR --logfile=/dev/null --pidfile=$PIDFILE
My tacfile is a python file which starts with these lines
#!/opt/python/bin/python
import os
from twisted.application import internet, service
from twisted.internet import reactor
from twisted.enterprise import adbapi
from twisted.plugin import getPlugins
from twisted.python import log
import labris.flyng.iflyng as iflyng
import labris.flyng.config as config
import labris.flyng.plugins as pplugins
import labris.flyng.protocols as flyng_protocols
But I get an error in this line:
import labris.flyng.iflyng as iflyng
The error is:
exceptions.ImportError: No module named labris.flyng.iflyng
Failed to load application: No module named labris.flyng.iflyng
But as you can understand twisted imports dont cause an error whereas labris imports fail. This application runs without any errors in linux.
And if it has something to do with it /opt/python/bin/python
is a symbolic link pointing to /usr/local/bin/python2.6
Both twisted and labris directories are under the path/usr/local/lib/python2.6/site-packages
Their permissions are correct and each of them has the same permissions.
The output of ls /usr/local/lib/python2.6/site-packages/labris/flyng
is__init__.py config.py db iflyng.py parsers plugins protocols.py
So I dont think there is an error with the module's path. I don't know what might be the cause of this error. Any clues, pointers is most welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您也可以尝试从简单的 python 脚本导入模块,看看它是否安装在正确的位置
You might also try to import the module from a simple python script to see if it is installed in the right place