[英]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.