2013-10-17 29 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