[Ironpython-users] no module named urllib

László Frank laszlo.frank at gmail.com
Fri Jul 15 08:13:03 EDT 2016


here is the output from ipy:

>>> for s in sys.path:print s
...
.
C:\Program Files (x86)\IronPython 2.7\Lib
C:\Program Files (x86)\IronPython 2.7\DLLs
C:\Program Files (x86)\IronPython 2.7
C:\Program Files (x86)\IronPython 2.7\lib\site-packages
C:\Python27\DLLs
C:\Python27\lib
C:\Python27\lib\plat-win
C:\Python27\lib\lib-tk
C:\Python27
C:\Python27\lib\site-packages

>>> import pkg_resources.extern.six.moves.urllib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named extern

>>>
>>> print sys.modules
{'_struct': <module '_struct' (built-in)>, 'collections': <module
'collections' from 'C:\Program Files (x86)\IronPython 2.7\L
ib\collections.py'>, 'bisect': <module 'bisect' from 'C:\Program Files
(x86)\IronPython 2.7\Lib\bisect.py'>, 'symbol': <modul
e 'symbol' from 'C:\Program Files (x86)\IronPython 2.7\Lib\symbol.py'>,
'site': <module 'site' from 'C:\Program Files (x86)\I
ronPython 2.7\Lib\site.py'>, '_weakref': <module '_weakref' (built-in)>,
'itertools': <module 'itertools' (built-in)>, '_bise
ct': <module '_bisect' (built-in)>, 'string': <module 'string' from
'C:\Program Files (x86)\IronPython 2.7\Lib\string.py'>, '
urlparse': <module 'urlparse' from 'C:\Program Files (x86)\IronPython
2.7\Lib\urlparse.py'>, '_abcoll': <module '_abcoll' fro
m 'C:\Program Files (x86)\IronPython 2.7\Lib\_abcoll.py'>, 'platform':
<module 'platform' from 'C:\Program Files (x86)\IronPy
thon 2.7\Lib\platform.py'>, '_warnings': <module '_warnings' (built-in)>,
'copy_reg': <module 'copy_reg' (built-in)>, '_heapq
': <module '_heapq' (built-in)>, 'zipfile': <module 'zipfile' from
'C:\Program Files (x86)\IronPython 2.7\Lib\zipfile.py'>, '
zipimport': <module 'zipimport' (built-in)>, 'io': <module 'io' from
'C:\Program Files (x86)\IronPython 2.7\Lib\io.py'>, 'bin
ascii': <module 'binascii' (built-in)>, 'warnings': <module 'warnings' from
'C:\Program Files (x86)\IronPython 2.7\Lib\warnin
gs.py'>, 'heapq': <module 'heapq' from 'C:\Program Files (x86)\IronPython
2.7\Lib\heapq.py'>, 'abc': <module 'abc' from 'C:\P
rogram Files (x86)\IronPython 2.7\Lib\abc.py'>, '_io': <module '_io'
(built-in)>, 'functools': <module 'functools' from 'C:\P
rogram Files (x86)\IronPython 2.7\Lib\functools.py'>, 'time': <module
'time' (built-in)>, '_weakrefset': <module '_weakrefset
' from 'C:\Program Files (x86)\IronPython 2.7\Lib\_weakrefset.py'>,
'fnmatch': <module 'fnmatch' from 'C:\Program Files (x86)
\IronPython 2.7\Lib\fnmatch.py'>, 'token': <module 'token' from 'C:\Program
Files (x86)\IronPython 2.7\Lib\token.py'>, 'sys':
 <module 'sys' (built-in)>, 'cStringIO': <module 'cStringIO' (built-in)>,
're': <module 're' (built-in)>, 'types': <module 't
ypes' from 'C:\Program Files (x86)\IronPython 2.7\Lib\types.py'>,
'pkg_resources': <module 'pkg_resources' from 'C:\Program F
iles (x86)\IronPython 2.7\lib\site-packages\pkg_resources.py'>, 'keyword':
<module 'keyword' from 'C:\Program Files (x86)\Iro
nPython 2.7\Lib\keyword.py'>, 'stat': <module 'stat' from 'C:\Program Files
(x86)\IronPython 2.7\Lib\stat.py'>, 'sysconfig':
<module 'sysconfig' from 'C:\Program Files (x86)\IronPython
2.7\Lib\sysconfig.py'>, 'ntpath': <module 'ntpath' from 'C:\Progr
am Files (x86)\IronPython 2.7\Lib\ntpath.py'>, 'pkgutil': <module 'pkgutil'
from 'C:\Program Files (x86)\IronPython 2.7\Lib\p
kgutil.py'>, 'nt': <module 'nt' (built-in)>, 'shutil': <module 'shutil'
from 'C:\Program Files (x86)\IronPython 2.7\Lib\shuti
l.py'>, 'os.path': <module 'ntpath' from 'C:\Program Files (x86)\IronPython
2.7\Lib\ntpath.py'>, 'linecache': <module 'lineca
che' from 'C:\Program Files (x86)\IronPython 2.7\Lib\linecache.py'>,
'_collections': <module '_collections' (built-in)>, '__b
uiltin__': <module '__builtin__' (built-in)>, 'UserDict': <module
'UserDict' from 'C:\Program Files (x86)\IronPython 2.7\Lib\
UserDict.py'>, 'traceback': <module 'traceback' from 'C:\Program Files
(x86)\IronPython 2.7\Lib\traceback.py'>, 'os': <module
 'os' from 'C:\Program Files (x86)\IronPython 2.7\Lib\os.py'>, 'imp':
<module 'imp' (built-in)>, 'thread': <module 'thread' (
built-in)>, 'zlib': <module 'zlib' (built-in)>, 'operator': <module
'operator' (built-in)>, 'genericpath': <module 'genericpa
th' from 'C:\Program Files (x86)\IronPython 2.7\Lib\genericpath.py'>,
'_functools': <module '_functools' (built-in)>, 'errno'
: <module 'errno' (built-in)>, '__main__': <module '__main__' (built-in)>,
'struct': <module 'struct' from 'C:\Program Files
(x86)\IronPython 2.7\Lib\struct.py'>}
>>>


and the same from Python27:


>>> for s in sys.path : print s
...

C:\Python27\lib\site-packages\twisted-16.2.0-py2.7-win32.egg
C:\windows\SYSTEM32\python27.zip
C:\Python27\DLLs
C:\Python27\lib
C:\Python27\lib\plat-win
C:\Python27\lib\lib-tk
C:\Python27
C:\Python27\lib\site-packages
>>>
>>>
>>>
>>> import pkg_resources.extern.six.moves.urllib
>>>
>>> print sys.modules
{'heapq': <module 'heapq' from 'C:\Python27\lib\heapq.pyc'>,
'email.iterators': <module 'email.iterators' from 'C:\Python27\l
ib\email\iterators.pyc'>, 'functools': <module 'functools' from
'C:\Python27\lib\functools.pyc'>, 'random': <module 'random'
from 'C:\Python27\lib\random.pyc'>, 'datetime': <module 'datetime'
(built-in)>, 'sysconfig': <module 'sysconfig' from 'C:\Pyt
hon27\lib\sysconfig.pyc'>, 'pprint': <module 'pprint' from
'C:\Python27\lib\pprint.pyc'>, 'email.MIMEImage': <email.LazyImpor
ter object at 0x02083850>, 'pkg_resources.extern.packaging': <module
'pkg_resources._vendor.packaging' from 'C:\Python27\lib\
site-packages\pkg_resources\_vendor\packaging\__init__.pyc'>,
'encodings.encodings': None, 'email.mime': <module 'email.mime'
 from 'C:\Python27\lib\email\mime\__init__.pyc'>, 'email.MIMEText':
<email.LazyImporter object at 0x020838D0>, 'copy': <modul
e 'copy' from 'C:\Python27\lib\copy.pyc'>, 'struct': <module 'struct' from
'C:\Python27\lib\struct.pyc'>, 'tempfile': <module
 'tempfile' from 'C:\Python27\lib\tempfile.pyc'>, 'base64': <module
'base64' from 'C:\Python27\lib\base64.pyc'>, 'pkg_resourc
es._vendor.warnings': None, 'platform': <module 'platform' from
'C:\Python27\lib\platform.pyc'>, 'pkg_resources._vendor': <mo
dule 'pkg_resources._vendor' from
'C:\Python27\lib\site-packages\pkg_resources\_vendor\__init__.pyc'>,
'email.warnings': None
, 'collections': <module 'collections' from
'C:\Python27\lib\collections.pyc'>, 'pkg_resources._vendor.sys': None,
'pkg_resou
rces._vendor.functools': None, 'email.Parser': <email.LazyImporter object
at 0x02083710>, 'zipimport': <module 'zipimport' (b
uilt-in)>, 'pkg_resources._vendor.packaging._structures': <module
'pkg_resources._vendor.packaging._structures' from 'C:\Pyth
on27\lib\site-packages\pkg_resources\_vendor\packaging\_structures.pyc'>,
'email.Header': <email.LazyImporter object at 0x020
836B0>, 'pkg_resources._vendor.packaging': <module
'pkg_resources._vendor.packaging' from 'C:\Python27\lib\site-packages\pkg_
resources\_vendor\packaging\__init__.pyc'>, 'pkg_resources.extern.sys':
None, 'pkg_resources.extern.packaging.markers': <modu
le 'pkg_resources._vendor.packaging.markers' from
'C:\Python27\lib\site-packages\pkg_resources\_vendor\packaging\markers.pyc'
>, 'zipfile': <module 'zipfile' from 'C:\Python27\lib\zipfile.pyc'>,
'textwrap': <module 'textwrap' from 'C:\Python27\lib\tex
twrap.pyc'>, 'ssl': <module 'ssl' from 'C:\Python27\lib\ssl.pyc'>,
'email.quoprimime': <module 'email.quoprimime' from 'C:\Py
thon27\lib\email\quoprimime.pyc'>, 'email.urllib': None,
'pkg_resources._vendor.weakref': None, 'signal': <module 'signal' (b
uilt-in)>, 'email.codecs': None, 'email.encoders': <module 'email.encoders'
from 'C:\Python27\lib\email\encoders.pyc'>, 'pkg_
resources._vendor.six.moves': <module 'pkg_resources._vendor.six.moves'
(built-in)>, 'quopri': <module 'quopri' from 'C:\Pyth
on27\lib\quopri.pyc'>, 'email.Message': <email.LazyImporter object at
0x020836F0>, 'cStringIO': <module 'cStringIO' (built-in
)>, 'encodings.cp850': <module 'encodings.cp850' from
'C:\Python27\lib\encodings\cp850.pyc'>, 'locale': <module 'locale' from
 'C:\Python27\lib\locale.pyc'>, 'pkg_resources._vendor.pprint': None,
'pkg_resources.extern.packaging.requirements': <module
'pkg_resources._vendor.packaging.requirements' from
'C:\Python27\lib\site-packages\pkg_resources\_vendor\packaging\requiremen
ts.pyc'>, 'email.quopriMIME': <email.LazyImporter object at 0x020837B0>,
'pkg_resources._vendor.re': None, 'encodings': <modu
le 'encodings' from 'C:\Python27\lib\encodings\__init__.pyc'>,
'email.Generator': <email.LazyImporter object at 0x02083690>,
'abc': <module 'abc' from 'C:\Python27\lib\abc.pyc'>, 'plistlib': <module
'plistlib' from 'C:\Python27\lib\plistlib.pyc'>, 'p
kg_resources._vendor.collections': None, 'email.MIMEAudio':
<email.LazyImporter object at 0x02083810>, 'urllib': <module 'url
lib' from 'C:\Python27\lib\urllib.pyc'>,
'pkg_resources._vendor.packaging.__about__': <module
'pkg_resources._vendor.packagin
g.__about__' from
'C:\Python27\lib\site-packages\pkg_resources\_vendor\packaging\__about__.pyc'>,
're': <module 're' from 'C:
\Python27\lib\re.pyc'>, 'pkg_resources.extern.packaging.version': <module
'pkg_resources._vendor.packaging.version' from 'C:\
Python27\lib\site-packages\pkg_resources\_vendor\packaging\version.pyc'>,
'ntpath': <module 'ntpath' from 'C:\Python27\lib\nt
path.pyc'>, 'email.quopri': None, 'pkg_resources._vendor.string': None,
'pkg_resources._vendor.__builtin__': None, 'email.err
ors': <module 'email.errors' from 'C:\Python27\lib\email\errors.pyc'>,
'email': <module 'email' from 'C:\Python27\lib\email\_
_init__.pyc'>, 'math': <module 'math' (built-in)>,
'pkg_resources.extern.six.moves': <module 'pkg_resources._vendor.six.moves
' (built-in)>, 'UserDict': <module 'UserDict' from
'C:\Python27\lib\UserDict.pyc'>, 'exceptions': <module 'exceptions' (built
-in)>, 'codecs': <module 'codecs' from 'C:\Python27\lib\codecs.pyc'>,
'importlib': <module 'importlib' from 'C:\Python27\lib\
importlib\__init__.pyc'>, '_functools': <module '_functools' (built-in)>,
'_locale': <module '_locale' (built-in)>, 'email.It
erators': <email.LazyImporter object at 0x020836D0>, 'socket': <module
'socket' from 'C:\Python27\lib\socket.pyc'>, 'thread':
 <module 'thread' (built-in)>, 'StringIO': <module 'StringIO' from
'C:\Python27\lib\StringIO.pyc'>, 'email.base64MIME': <emai
l.LazyImporter object at 0x02083790>, 'pkg_resources': <module
'pkg_resources' from 'C:\Python27\lib\site-packages\pkg_resour
ces\__init__.pyc'>, 'weakref': <module 'weakref' from
'C:\Python27\lib\weakref.pyc'>, 'itertools': <module 'itertools' (built
-in)>, 'email.Charset': <email.LazyImporter object at 0x02083610>, 'os':
<module 'os' from 'C:\Python27\lib\os.pyc'>, 'pkg_re
sources._vendor.packaging.version': <module
'pkg_resources._vendor.packaging.version' from
'C:\Python27\lib\site-packages\pkg
_resources\_vendor\packaging\version.pyc'>, '__future__': <module
'__future__' from 'C:\Python27\lib\__future__.pyc'>, '_coll
ections': <module '_collections' (built-in)>, 'email.uu': None, '_sre':
<module '_sre' (built-in)>, '__builtin__': <module '_
_builtin__' (built-in)>, 'email.FeedParser': <email.LazyImporter object at
0x02083670>, 'email.calendar': None, 'email.charse
t': <module 'email.charset' from 'C:\Python27\lib\email\charset.pyc'>,
'operator': <module 'operator' (built-in)>, 'email.Err
ors': <email.LazyImporter object at 0x02083650>, '_heapq': <module '_heapq'
(built-in)>, 'email.feedparser': <module 'email.f
eedparser' from 'C:\Python27\lib\email\feedparser.pyc'>, 'email.socket':
None, 'pkgutil': <module 'pkgutil' from 'C:\Python27
\lib\pkgutil.pyc'>, 'imp': <module 'imp' (built-in)>, 'errno': <module
'errno' (built-in)>, 'pkg_resources._vendor.packaging.
requirements': <module 'pkg_resources._vendor.packaging.requirements' from
'C:\Python27\lib\site-packages\pkg_resources\_vend
or\packaging\requirements.pyc'>, '_socket': <module '_socket' from
'C:\Python27\DLLs\_socket.pyd'>, 'binascii': <module 'bina
scii' (built-in)>, 'email.Utils': <email.LazyImporter object at
0x02083730>, 'sre_constants': <module 'sre_constants' from 'C
:\Python27\lib\sre_constants.pyc'>, 'email.MIMEMessage':
<email.LazyImporter object at 0x02083870>, 'email._parseaddr': <modu
le 'email._parseaddr' from 'C:\Python27\lib\email\_parseaddr.pyc'>,
'email.sys': None, 'os.path': <module 'ntpath' from 'C:\P
ython27\lib\ntpath.pyc'>, 'pkg_resources._vendor.sre_constants': None,
'pkg_resources._vendor.six.moves.urllib': <module 'pkg
_resources._vendor.six.moves.urllib' (built-in)>, '_warnings': <module
'_warnings' (built-in)>, 'pkg_resources.extern.six.mov
es.urllib': <module 'pkg_resources._vendor.six.moves.urllib' (built-in)>,
'encodings.__builtin__': None, 'email.MIMENonMultip
art': <email.LazyImporter object at 0x020838B0>,
'pkg_resources._vendor.packaging._compat': <module 'pkg_resources._vendor.pa
ckaging._compat' from
'C:\Python27\lib\site-packages\pkg_resources\_vendor\packaging\_compat.pyc'>,
'_codecs': <module '_code
cs' (built-in)>, 'email.os': None, 'email.utils': <module 'email.utils'
from 'C:\Python27\lib\email\utils.pyc'>, 'encodings.c
p1252': <module 'encodings.cp1252' from
'C:\Python27\lib\encodings\cp1252.pyc'>, 'nturl2path': <module 'nturl2path'
from 'C:\
Python27\lib\nturl2path.pyc'>, 'email.time': None, '_struct': <module
'_struct' (built-in)>, 'email.email': None, 'hashlib':
<module 'hashlib' from 'C:\Python27\lib\hashlib.pyc'>, 'keyword': <module
'keyword' from 'C:\Python27\lib\keyword.pyc'>, 'uu'
: <module 'uu' from 'C:\Python27\lib\uu.pyc'>,
'pkg_resources._vendor.pyparsing': <module
'pkg_resources._vendor.pyparsing' f
rom 'C:\Python27\lib\site-packages\pkg_resources\_vendor\pyparsing.pyc'>,
'zlib': <module 'zlib' (built-in)>, 'pkg_resources.
_vendor.itertools': None, 'pkg_resources._vendor.copy': None,
'email.random': None, 'encodings.aliases': <module 'encodings.a
liases' from 'C:\Python27\lib\encodings\aliases.pyc'>, 'fnmatch': <module
'fnmatch' from 'C:\Python27\lib\fnmatch.pyc'>, 'sre
_parse': <module 'sre_parse' from 'C:\Python27\lib\sre_parse.pyc'>,
'traceback': <module 'traceback' from 'C:\Python27\lib\tr
aceback.pyc'>, 'copy_reg': <module 'copy_reg' from
'C:\Python27\lib\copy_reg.pyc'>, 'sre_compile': <module 'sre_compile' from
 'C:\Python27\lib\sre_compile.pyc'>,
'pkg_resources._vendor.packaging.specifiers': <module
'pkg_resources._vendor.packaging.s
pecifiers' from
'C:\Python27\lib\site-packages\pkg_resources\_vendor\packaging\specifiers.pyc'>,
'_hashlib': <module '_hashli
b' from 'C:\Python27\DLLs\_hashlib.pyd'>, '_random': <module '_random'
(built-in)>, 'site': <module 'site' from 'C:\Python27\
lib\site.pyc'>, 'pkg_resources.extern.six': <module
'pkg_resources._vendor.six' from 'C:\Python27\lib\site-packages\pkg_resou
rces\_vendor\six.py'>, 'email.base64': None, 'io': <module 'io' from
'C:\Python27\lib\io.pyc'>, '__main__': <module '__main__
' (built-in)>, 'shutil': <module 'shutil' from
'C:\Python27\lib\shutil.pyc'>, 'calendar': <module 'calendar' from
'C:\Python2
7\lib\calendar.pyc'>, 'email.message': <module 'email.message' from
'C:\Python27\lib\email\message.pyc'>, 'string': <module '
string' from 'C:\Python27\lib\string.pyc'>, 'urlparse': <module 'urlparse'
from 'C:\Python27\lib\urlparse.pyc'>, 'email.MIMEB
ase': <email.LazyImporter object at 0x02083830>, 'importlib.sys': None,
'strop': <module 'strop' (built-in)>, 'linecache': <m
odule 'linecache' from 'C:\Python27\lib\linecache.pyc'>,
'encodings.codecs': None, '_abcoll': <module '_abcoll' from 'C:\Pyth
on27\lib\_abcoll.pyc'>, 'email.binascii': None, 'email.MIMEMultipart':
<email.LazyImporter object at 0x02083890>, 'nt': <modu
le 'nt' (built-in)>, 'pkg_resources.extern': <module 'pkg_resources.extern'
from 'C:\Python27\lib\site-packages\pkg_resources
\extern\__init__.pyc'>, 'genericpath': <module 'genericpath' from
'C:\Python27\lib\genericpath.pyc'>, 'stat': <module 'stat'
from 'C:\Python27\lib\stat.pyc'>, '_ssl': <module '_ssl' from
'C:\Python27\DLLs\_ssl.pyd'>, 'warnings': <module 'warnings' fr
om 'C:\Python27\lib\warnings.pyc'>, 'pkg_resources._vendor.six': <module
'pkg_resources._vendor.six' from 'C:\Python27\lib\si
te-packages\pkg_resources\_vendor\six.py'>, 'email.re': None, 'sys':
<module 'sys' (built-in)>, 'email.Encoders': <email.Lazy
Importer object at 0x02083630>, 'email.parser': <module 'email.parser' from
'C:\Python27\lib\email\parser.pyc'>, 'email.cStri
ngIO': None, 'types': <module 'types' from 'C:\Python27\lib\types.pyc'>,
'pkg_resources.extern.packaging.specifiers': <module
 'pkg_resources._vendor.packaging.specifiers' from
'C:\Python27\lib\site-packages\pkg_resources\_vendor\packaging\specifiers.
pyc'>, 'email.base64mime': <module 'email.base64mime' from
'C:\Python27\lib\email\base64mime.pyc'>, 'pkg_resources._vendor.pa
ckaging.markers': <module 'pkg_resources._vendor.packaging.markers' from
'C:\Python27\lib\site-packages\pkg_resources\_vendor
\packaging\markers.pyc'>, '_weakref': <module '_weakref' (built-in)>,
'pkg_resources.extern.pyparsing': <module 'pkg_resource
s._vendor.pyparsing' from
'C:\Python27\lib\site-packages\pkg_resources\_vendor\pyparsing.pyc'>,
'_io': <module '_io' (built-i
n)>, '_weakrefset': <module '_weakrefset' from
'C:\Python27\lib\_weakrefset.pyc'>, 'email.string': None, 'time': <module
'tim
e' (built-in)>}
>>>


On Fri, Jul 15, 2016 at 11:01 AM, Langbehn, Thimo <t.langbehn at euroimmun.de>
wrote:

> Hi László,
>
> > I get the same error with the import statement "from six.moves import
> urllib"
>
> > Well, I can import six, but not urllib through six.
>
> there is a difference here. The above statement tries to import urllib
> from the normal six module, which does not contain such a module.
>
> The module your program wants ist pkg_resources.extern.six.moves.urllib
> Therefore, in ipy you should do:
>
> import pkg_resources.extern.six.moves.urllib
>
> However, for this to work, your site-packages must be in the IronPython
> search path. Do not just set the search path to the same as Python2.7, the
> core packages do differ.
>
> Could you, in ipy, do:
>
>     import sys
>     print(sys.path)
>     import pkg_resources.extern.six.moves.urllib
>
> and provide the results?
>
> Cheers,
>
> Thimo
>
> P.S: please keep the mails on the list.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20160715/b99339ec/attachment.html>


More information about the Ironpython-users mailing list