在Biopython安装说明中,它说如果Biopython无效,我应该这样做:
export PYTHONPATH = $ PYTHONPATH':/ directory / where / you / put / Biopython'
我尝试在〜目录中使用Biopython目录的名称(或者通过〜目录的所有内容)在Cygwin中执行此操作,但是当我通过进入Python解释器并输入
进行测试时从Bio.Seq导入Seq
它说该模块不存在。
我如何制作它以便我不必在Biopython目录中才能导入Seq?
答案 0 :(得分:2)
您可以将目录添加到sys.path
列表
import sys
biopythondir = '/where/you/put/biopython'
if biopythondir not in sys.path:
sys.path.append(biopythondir)
# import seq
或者,为了获得比使用环境变量和sys.path
更优雅的解决方案,请参阅how to use .pth files to extend sys.path。
答案 1 :(得分:2)
你写了“(或者它的所有内容经过〜目录)”。我认为您需要使用完整的目录路径。并且~
在“:”之后不会立即展开,因此请改为使用$HOME
:
export PYTHONPATH = $ PYTHONPATH“:$ HOME / directory / where / you / put / Biopython”
(注意使用双引号而不是单引号,以便扩展$HOME
。)