我在/opt
目录中安装了一个应用程序,并将其根添加到PATH(适用于所有想要使用它的用户)。现在,当我从用户调用主脚本时,它工作正常,但其他用户报告相同的错误:
user@server:~$ ragout.py -h
Traceback (most recent call last):
File "/opt/ragout-2.0-linux-x86_64/ragout.py", line 33, in <module>
from ragout.main import main
File "/opt/ragout-2.0-linux-x86_64/ragout.py", line 33, in <module>
from ragout.main import main
ImportError: No module named main
这是主脚本:
#!/usr/bin/env python2.7
#(c) 2013-2014 by Authors
#This file is a part of Ragout program.
#Released under the BSD license (see LICENSE file)
"""
This script does all the necessary preparations
and invokes Ragout
"""
import os
import sys
LIB_DIR = "lib"
#Check Python version
if sys.version_info[:2] != (2, 7):
print("Error: Ragout requires Python version 2.7 ({0}.{1} detected)."
.format(sys.version_info[0], sys.version_info[1]))
sys.exit(-1)
#Setting executable paths
ragout_root = os.path.dirname(os.path.realpath(__file__))
lib_absolute = os.path.join(ragout_root, LIB_DIR)
sys.path.insert(0, lib_absolute)
sys.path.insert(0, ragout_root)
os.environ["PATH"] = lib_absolute + os.pathsep + os.environ["PATH"]
#Ragout entry point
from ragout.main import main
sys.exit(main())
我认为脚本可能会在展开ragout_root
和lib_absolute
时遇到一些问题,因此我在print(ragout_root, lib_absolute)
之前添加了from ragout.main import main
来查看,发生了什么。现在,当我从用户运行应用程序时,我得到了这个:
me@server:~$ ragout.py -h
('/opt/ragout-2.0-linux-x86_64', '/opt/ragout-2.0-linux-x86_64/lib')
usage: ragout.py [-h] [-o output_dir] [-s {sibelia,maf,hal}] [--refine]
[--solid-scaffolds] [--overwrite] [--repeats] [--debug]
[-t THREADS] [--version]
recipe_file
...
用户得到此
user@server:~$ ragout.py -h
('/opt/ragout-2.0-linux-x86_64', '/opt/ragout-2.0-linux-x86_64/lib')
('/opt/ragout-2.0-linux-x86_64', '/opt/ragout-2.0-linux-x86_64/lib')
Traceback (most recent call last):
File "/opt/ragout-2.0-linux-x86_64/ragout.py", line 33, in <module>
from ragout.main import main
File "/opt/ragout-2.0-linux-x86_64/ragout.py", line 33, in <module>
from ragout.main import main
ImportError: No module named main
无论出于何种原因,它会打印两次 - 尽管路径是正确的 - 它仍然无法从本地模块导入。有任何想法吗?
答案 0 :(得分:2)
我认为这是一个权限问题。请参阅用户报告非常类似问题的this Stack Overflow question。
解决方案:确保所有适当的用户都在至少文件夹读取权限的用户组中。