简体   繁体   English

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

[英]My SDK has its own python interpreter. How do I install modules for it?

I recently downloaded the python-ogre SDK, which appears to include its own python interpreter. 我最近下载了python-ogre SDK,该SDK似乎包含其自己的python解释器。

I say "appears" because this interpreter also seems to depend on the standard python 2.7.2 installation. 我说“出现”是因为该解释器似乎也依赖于标准的python 2.7.2安装。 I tried uninstalling the latter, and the python-ogre SDK interpreter complains that python27.dll is missing from my computers. 我尝试卸载后者,而python-ogre SDK解释器抱怨我的计算机缺少python27.dll。

I really don't understand how the two interpreters are related, and the python-ogre SDK forum topic has been less than helpful. 我真的不明白这两个解释器之间的关系,并且python-ogre SDK论坛主题没有什么帮助。

I really need to instally PyYAML such that the python-ogre interpreter has access to it. 确实需要安装PyYAML,以便python-ogre解释器可以访问它。 I successfully installed PyYAML (the installer detected python 2.7) and the standard python console manages to import it without any issues. 我成功安装了PyYAML(安装程序检测到python 2.7),并且标准的python控制台可以成功导入它。

The python-ogre SDK interpreter, however, complains that there is no module by that name. 但是,python-ogre SDK解释器抱怨该名称没有模块。

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 在此先感谢您,Blz

EDIT MichaelMior hinted at the possibility that this involved my sys.path. 编辑 MichaelMior暗示这可能涉及到我的sys.path。 I'm rather new to python, so any explanations are welcome. 我是python的新手,所以欢迎您提供任何解释。

The output of sys.path for the standard python installation is: 标准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

The output of the python-ogre SDK is: 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

EDIT 2: 编辑2:

Okay I got it! 好吧,我明白了! I just did sys.path.append('C:\\Python27\\lib\\site-packages') 我只是做了sys.path.append('C:\\ Python27 \\ lib \\ site-packages')

Apparently, 3rd party modules get installed to that directory. 显然,第3方模块已安装到该目录。 Is this safe to do? 这样安全吗? Do I risk creating any sort of conflicts? 我有冒任何形式的冲突的风险吗?

Each Python interpreter has its sys.path, which it will use to search for modules. 每个Python解释器都有其sys.path,它将用于搜索模块。

When you installed PyYAML, it got installed to the directory for the plain Python interpreter (C:\\Python27\\lib\\site-packages). 当您安装PyYAML时,它将安装到纯Python解释器的目录(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. 当您尝试从python-ogre导入它时,它根本不知道要在那里查找,因此找不到它。 That's what adding the folder to sys.path did - tell python-ogre to look in that folder for modules. 这就是将文件夹添加到sys.path的过程-告诉python-ogre在该文件夹中查找模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何安装Python / Django模块? - How do I install Python/Django Modules? 我在哪里放置或如何安装我自己的 Python 模块 - Where do I place or how do I install my own Python module VS Code 需要一个 Python 解释器。 为什么这是必要的? - VS Code needs a Python Interpreter. Why is this necessary? Redux:在Hadoop中运行时,如何让Jython在其自己的jar文件中使用存储在Lib中的Python模块? - Redux: How do I get Jython to use Python modules stored in Lib within its own jar file when running in Hadoop? 我如何使用IPython作为我的Emacs Python解释器? - How do I use IPython as my Emacs Python interpreter? 找不到工作的 python 解释器。 团结,Firebase - Could not find a working python interpreter. Unity, Firebase 如何创建自定义 python 解释器? 即某些模块已经包括在内? - How do I create a custom python interpreter? i.e. with certain modules already included? 脚本在解释器中运行奇怪。 -i标志有什么影响? - Script runs strangely in interpreter. What is the effect of the -i flag? 我该如何在Enthought Canopy中更改我的Python解释器? - How do I change my Python interpreter in Enthought Canopy? 如何防止python解释器查看和导入未安装的模块; 不属于系统? - How do I prevent python interpreter to see and import modules that are not installed; do not belong to the system?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM