load pyd files from a zip from embedded python

前端 未结 4 1156
轻奢々
轻奢々 2021-01-12 19:09

I can load Python modules (.py, .pyc, .pyd) from a zip file by calling \"import some_module\" from a Python interpreter only after sys.path has been extended to include the

4条回答
  •  -上瘾入骨i
    2021-01-12 19:35

    this sounds like the same kind of issues I had trying to compile an app with py2exe. see here: http://www.py2exe.org/index.cgi/Tutorial, look at section 5.2. Same thing happens... first time you try to use memimporter, it crashes with a similar error message. Basically, for python 2.6+ you need to have the exact version of the runtime library in the path, and a manifest that points to it. Since you are using embedded python, i don't know how it all works, but maybe that will get you closer.

    i'd start by putting the 'correct' version of the runtime dll somewhere, and in your python code, before importing zipextimporter, append the path of the correct runtime to sys.path and see if that fixes it. not sure how you get the manifest in there for an embedded python though. it might need to be included in the parent app's manifest.

    edit: BTW, i forgot, we found another way around this issue as well. I forget the exact details, but what happens is that your app loads the default version of the runtime, and then python asks for its version, and it finds one in c:\python{26,27} and it doesn't match. The simplest way to solve this problem is to delete c:\python\msvcr90.dll. Then, python won't hit the local (old) version of the dll which might not work with your app's manifest, and both of them will have to go out and get the current version from the windows directory, which will match.

提交回复
热议问题