我的 SDK 有自己的 python 解释器。如何为其安装模块?

发布于 2025-01-01 14:04:57 字数 1296 浏览 0 评论 0原文

我最近下载了 python-ogre SDK,它似乎包含它自己的 python 解释器。

我说“出现”是因为这个解释器似乎也依赖于标准 python 2.7.2 安装。我尝试卸载后者,但 python-ogre SDK 解释器抱怨我的计算机中缺少 python27.dll。

我真的不明白这两个解释器是如何相关的,以及 python-ogre SDK 论坛主题 没什么帮助。

真的需要安装 PyYAML,以便 python-ogre 解释器可以访问它。我成功安装了 PyYAML(安装程序检测到 python 2.7),标准 python 控制台成功导入它,没有任何问题。

然而,python-ogre SDK 解释器抱怨没有该名称的模块。

完全迷路了。有人可以指出我正确的方向和/或解释发生了什么吗?

预先非常感谢, Blz

编辑 MichaelMior 暗示这可能涉及我的 sys.path。我对 python 很陌生,所以欢迎任何解释。

标准 python 安装的 sys.path 的输出是:

C:\Windows\system32\python27.zip
C:\Python27\lib\site-packages\pip-1.0.2-py.2.7.egg
C:\Python27\DLLs
C:\Python27\lib\plat-win
C:\Python27\lib\lib-tk
C:\Python27
C:\Python27\lib\site-packages

python-ogre SDK 的输出是:

C:\Windows\system32\python27.zip
C:\python-ogre\[SDK]\DLLs
C:\python-ogre\[SDK]\lib
C:\python-ogre\[SDK]\lib\plat-win
C:\python-ogre\[SDK]\lib\lib-tk
C:\python-ogre\[SDK]
C:\python-ogre\[SDK]\lib\site-packages

编辑 2:

好的,我明白了!我刚刚做了 sys.path.append('C:\Python27\lib\site-packages')

显然,第 3 方模块已安装到该目录。这样做安全吗?我是否有造成任何冲突的风险?

I recently downloaded the python-ogre SDK, which appears to include its own python interpreter.

I say "appears" because this interpreter also seems to depend on the standard python 2.7.2 installation. I tried uninstalling the latter, and the python-ogre SDK interpreter complains that python27.dll is missing from my computers.

I really don't understand how the two interpreters are related, and the python-ogre SDK forum topic has been less than helpful.

I really need to instally PyYAML such that the python-ogre interpreter has access to it. I successfully installed PyYAML (the installer detected python 2.7) and the standard python console manages to import it without any issues.

The python-ogre SDK interpreter, however, complains that there is no module by that name.

I'm completely lost. Can someone point me in the right direction and/or explain what is going on?

With many thanks in advance,
Blz

EDIT
MichaelMior hinted at the possibility that this involved my sys.path. I'm rather new to python, so any explanations are welcome.

The output of sys.path for the standard python installation is:

C:\Windows\system32\python27.zip
C:\Python27\lib\site-packages\pip-1.0.2-py.2.7.egg
C:\Python27\DLLs
C:\Python27\lib\plat-win
C:\Python27\lib\lib-tk
C:\Python27
C:\Python27\lib\site-packages

The output of the python-ogre SDK is:

C:\Windows\system32\python27.zip
C:\python-ogre\[SDK]\DLLs
C:\python-ogre\[SDK]\lib
C:\python-ogre\[SDK]\lib\plat-win
C:\python-ogre\[SDK]\lib\lib-tk
C:\python-ogre\[SDK]
C:\python-ogre\[SDK]\lib\site-packages

EDIT 2:

Okay I got it! I just did sys.path.append('C:\Python27\lib\site-packages')

Apparently, 3rd party modules get installed to that directory. Is this safe to do? Do I risk creating any sort of conflicts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

り繁华旳梦境 2025-01-08 14:04:57

每个Python解释器都有它的sys.path,它将用来搜索模块。

当您安装 PyYAML 时,它被安装到普通 Python 解释器的目录 (C:\Python27\lib\site-packages)。当你尝试从 python-ogre 导入它时,它不知道去那里,所以它找不到它。这就是将文件夹添加到 sys.path 所做的事情 - 告诉 python-ogre 在该文件夹中查找模块。

Each Python interpreter has its sys.path, which it will use to search for modules.

When you installed PyYAML, it got installed to the directory for the plain Python interpreter (C:\Python27\lib\site-packages). When you try to import it from python-ogre, it has no idea to look there so it can't find it. That's what adding the folder to sys.path did - tell python-ogre to look in that folder for modules.

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