2013-10-17 27 views
0

我想创建一个在选择这个简单的Python代码上执行的快捷方式。 它只是从库Biopython中运行一个函数。导入python库gedit外部工具时出错

#!/Users/USERNAME/Library/Enthought/Canopy_64bit/User/bin/python 

from Bio.Seq import reverse_complement 
import sys 

print reverse_complement(sys.stdin.read().rstrip()) 

但我得到这个错误:

ImportError: No module named Bio.Seq 

它没有任何意义,我因为如果我从终端

$ /Users/USERNAME/Library/Enthought/Canopy_64bit/User/bin/python 
>>> from Bio.Seq import reverse_complement 

图书馆是没有任何问题的进口运行。 我做错了什么?我如何告诉gedit在哪里寻找图书馆?

+1

如果最后一条命令前加上'打印sys.executable',您能得到什么? (*运行在终端*,*运行不在终端*) – falsetru

+0

gedit: '/ Users/gioelelamanno/Library/Enthought/Canopy_64bit/User/Resources/Python.app/Contents/MacOS/Python' Terminal: '/ Users/gioelelamanno/Library/Enthought/Canopy_64bit/User/bin/python' – Gioelelm

回答

1

这是您的路径问题。 这应该工作:

#!/Users/USERNAME/Library/Enthought/Canopy_64bit/User/bin/python 

import sys 
sys.path.append('*yourpath of Bio module*') 
from Bio.Seq import reverse_complement 


print reverse_complement(sys.stdin.read().rstrip()) 
+0

任何线索为什么gedit使用: '/Users/gioelelamanno/Library/Enthought/Canopy_64bit/User/Resources/Python.app/C ontents/MacOS/Python' 而不是我告诉他使用? – Gioelelm

+0

如何避免我的选择后发送到新行? – Gioelelm

+0

我对gedit不熟悉,你的shebang(第一行)对我来说很好。 – Ernst