Modify ↓
Ticket #523 (closed defect: fixed)
Can't use CherryPy due to KeyError
| Reported by: | dn@… | Owned by: | matysek |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | PyInstaller | Version: | 1.5.1 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
CherryPy? uses the following code to be compatible with both Python 3 and Python 2. When I attempt to use this with PyInstaller?, I get a KeyError? rather then an ImportError?, so execution fails:
try:
# Python 3
from urllib.parse import urljoin, urlencode
from urllib.parse import quote, quote_plus
from urllib.request import unquote, urlopen
from urllib.request import parse_http_list, parse_keqv_list
except ImportError:
# Python 2
from urlparse import urljoin
from urllib import urlencode, urlopen
from urllib import quote, quote_plus
from urllib import unquote
from urllib2 import parse_http_list, parse_keqv_list
Traceback (most recent call last):
File "<string>", line 18, in <module>
File "c:\Source\NS2Update\pyinstaller-1.5.1\iu.py", line 436, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "c:\Source\NS2Update\pyinstaller-1.5.1\iu.py", line 521, in doimport
exec co in mod.__dict__
File "c:\Source\NS2Update\build\pyi.win32\console\outPYZ1.pyz/webserver.webserver", line 2, in <module>
File "c:\Source\NS2Update\pyinstaller-1.5.1\iu.py", line 436, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "c:\Source\NS2Update\pyinstaller-1.5.1\iu.py", line 521, in doimport
exec co in mod.__dict__
File "c:\Source\NS2Update\build\pyi.win32\console\outPYZ1.pyz/cherrypy", line62, in <module>
File "c:\Source\NS2Update\pyinstaller-1.5.1\iu.py", line 436, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "c:\Source\NS2Update\pyinstaller-1.5.1\iu.py", line 521, in doimport
exec co in mod.__dict__
File "c:\Source\NS2Update\build\pyi.win32\console\outPYZ1.pyz/cherrypy._cpcompat", line 146, in <module>
File "c:\Source\NS2Update\pyinstaller-1.5.1\iu.py", line 454, in importHook
del sys.modules[fqname]
KeyError: 'urllib.parse'
As far as I can tell, a hook really wouldn't help this, as the 'urllib.parse' module doesn't actually exist in Python 2. I've tried using "excludes=urllib.parse?" as an argument to Analsys, but that doesn't seem to help.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

This seems to be related to this mailing list thread: http://groups.google.com/group/pyinstaller/browse_thread/thread/af6a6339539e7d73
Citation: