[issue2000] .pyd modules not found when importing from .zip archives (library.zip)
hskupin
bugs at mercurial.selenic.com
Wed Jan 27 15:38:51 UTC 2010
New submission from hskupin <hskupin at mozilla.com>:
In short words explained there is a bug when .pyd modules have to be loaded
from inside a zip archive. In my case I want to use mercurial.commands and
importing this module results in the error shown below:
Traceback (most recent call last):
File "z:/data/testing/run_tests.py", line 11, in <module>
from mercurial import commands, hg, ui
File "c:\mozilla-build\python25\lib\commands.pyc", line 9, in <module>
outtext = commands.getoutput(cmd)
File "mercurial\i18n.pyc", line 51, in <module>
File "mercurial\util.pyc", line 17, in <module>
ImportError: No module named osutil
In detail:
To implement automated functional test-runs on Windows I'm using the
MozillaBuild environment
(http://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32/MozillaBuildSetup-Latest.exe)
which comes with a lot of helpful tools. Mercurial is included too but not
as a Python module.
When you want to use Mercurial from inside your Python script you would have
to import the Mercurial modules via:
if sys.platform == 'win32':
sys.path.append(r'c:\mozilla-build\hg\library.zip')
from mercurial import commands, hg, ui
But doing that and calling a function from commands will cause the mentioned
error above.
Resolution:
There is a workaround to circumvent this bug. Extract the library.zip into
another folder and use that one in your path:
if sys.platform == 'win32':
sys.path.append(r'c:\mozilla-build-libs\hg')
from mercurial import commands, hg, ui
Now everything works fine.
It really looks like that importing .pyd files from zip archives fail.
----------
messages: 11518
nosy: hskupin
priority: bug
status: unread
title: .pyd modules not found when importing from .zip archives (library.zip)
____________________________________________________
Mercurial issue tracker <bugs at mercurial.selenic.com>
<http://mercurial.selenic.com/bts/issue2000>
____________________________________________________
More information about the Mercurial-devel
mailing list