如何设置Cygwin上的PYTHONPATH? [英] How do I set the PYTHONPATH on Cygwin?

查看:941
本文介绍了如何设置Cygwin上的PYTHONPATH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Biopython安装说明中,它说如果Biopython不工作,我应该这样做:

In the Biopython installation instructions, it says that if Biopython doesn't work I'm supposed to do this:

export PYTHONPATH = $ PYTHONPATH':/ directory / where / you / put / Biopython'

export PYTHONPATH = $PYTHONPATH':/directory/where/you/put/Biopython'

我试图在〜目录中使用Biopython目录的名称(或者所有的过去〜目录),但是当我测试它通过进入Python解释器并输入

I tried doing that in Cygwin from the ~ directory using the name of the Biopython directory (or everything of it past the ~ directory), but when I tested it by going into the Python interpreter and typing in



从Bio.Seq import Seq

From Bio.Seq import Seq


它表示模块不存在。

如何使它不必在Biopython目录中才能导入Seq?

How do I make it so that I don't have to be in the Biopython directory to be able to import Seq?

推荐答案

您可以将目录添加到 sys.path 列表

You can add the directory to your sys.path list

import sys
biopythondir = '/where/you/put/biopython'
if biopythondir not in sys.path:
  sys.path.append(biopythondir)

# import seq

或者,对于一个比环境变量更优雅的解决方案, sys.path ,请参阅如何使用.pth文件扩展sys.path

Or, for a more elegant solution than mucking around with environment variables and sys.path, see how to use .pth files to extend sys.path.

这篇关于如何设置Cygwin上的PYTHONPATH?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆