如何在 Cygwin 上设置 PYTHONPATH?
在 Biopython 安装说明中,它说如果 Biopython 不起作用,我应该这样做:
export PYTHONPATH = $PYTHONPATH':/directory/where/you/put/Biopython'
我尝试在 Cygwin 中从 ~ 中执行此操作目录使用 Biopython 目录的名称(或 ~ 目录之后的所有内容),但是当我通过进入 Python 解释器并输入来测试它时
<块引用>从 Bio.Seq 导入 Seq
表示该模块不存在。
我该如何做到这样我不必在 Biopython 目录中就能够导入 Seq?
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'
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
From Bio.Seq import Seq
It said the module doesn't exist.
How do I make it so that I don't have to be in the Biopython directory to be able to import Seq?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您写了“(或 ~ 目录之后的所有内容)”。我认为您需要使用完整目录路径。并且
~
不会在 ':' 之后立即展开,因此请使用$HOME
代替:export PYTHONPATH = $PYTHONPATH":$HOME/directory/where/you/put /Biopython”
(请注意使用双引号而不是单引号,因此
$HOME
被扩展。)You wrote "(or everything of it past the ~ directory)". I think you need to use the full directory path. And
~
isn't expanded immediately after a ':', so use$HOME
instead:export PYTHONPATH = $PYTHONPATH":$HOME/directory/where/you/put/Biopython"
(Note the use of double rather than single quotes so
$HOME
is expanded.)您可以将该目录添加到您的
sys.path
列表中,或者,如果需要比摆弄环境变量和
sys.path
更优雅的解决方案,请参阅 如何使用 .pth 文件扩展 sys.path。You can add the directory to your
sys.path
listOr, for a more elegant solution than mucking around with environment variables and
sys.path
, see how to use .pth files to extend sys.path.