简体   繁体   中英

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.

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM