如何在 Cygwin 上设置 PYTHONPATH?

发布于 2024-12-01 18:05:07 字数 371 浏览 3 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陈甜 2024-12-08 18:05:07

您写了“(或 ~ 目录之后的所有内容)”。我认为您需要使用完整目录路径。并且 ~ 不会在 ':' 之后立即展开,因此请使用 $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.)

你怎么这么可爱啊 2024-12-08 18:05:07

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

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

# import seq

,或者,如果需要比摆弄环境变量和 sys.path 更优雅的解决方案,请参阅 如何使用 .pth 文件扩展 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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文