V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
myrual
V2EX  ›  问与答

为什么 ubuntu 上面无法import urllib.request?

  •  
  •   myrual · 2011-03-23 22:29:50 +08:00 · 5070 次点击
    这是一个创建于 4783 天前的主题,其中的信息可能已经有所发展或是发生改变。
    环境是
    Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
    [GCC 4.4.3] on linux2

    问题太奇怪了。
    >>> import urllib
    >>> dir(urllib)
    ['ContentTooShortError', 'FancyURLopener', 'MAXFTPCACHE', 'URLopener', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__version__', '_ftperrors', '_have_ssl', '_hextochr', '_hostprog', '_is_unicode', '_localhost', '_noheaders', '_nportprog', '_passwdprog', '_portprog', '_queryprog', '_safemaps', '_tagprog', '_thishost', '_typeprog', '_urlopener', '_userprog', '_valueprog', 'addbase', 'addclosehook', 'addinfo', 'addinfourl', 'always_safe', 'basejoin', 'ftpcache', 'ftperrors', 'ftpwrapper', 'getproxies', 'getproxies_environment', 'localhost', 'main', 'noheaders', 'os', 'pathname2url', 'proxy_bypass', 'proxy_bypass_environment', 'quote', 'quote_plus', 'reporthook', 'socket', 'splitattr', 'splithost', 'splitnport', 'splitpasswd', 'splitport', 'splitquery', 'splittag', 'splittype', 'splituser', 'splitvalue', 'ssl', 'string', 'sys', 'test', 'test1', 'thishost', 'time', 'toBytes', 'unquote', 'unquote_plus', 'unwrap', 'url2pathname', 'urlcleanup', 'urlencode', 'urlopen', 'urlretrieve']
    >>>
    4 条回复    1970-01-01 08:00:00 +08:00
    fanzeyi
        1
    fanzeyi  
       2011-03-23 22:34:48 +08:00
    那个是python3.*的吧。。
    est
        2
    est  
       2011-03-23 22:36:39 +08:00
    request是方法当然无法import
    myrual
        3
    myrual  
    OP
       2011-03-23 22:41:31 +08:00
    奇怪的是我在windows上面用的是activestate的2.6版本。有这个库的。
    myrual
        4
    myrual  
    OP
       2011-03-23 23:09:18 +08:00
    搞定了。
    我引用了python weather api库,但是在windows上面是直接从google code下载的代码
    linux上面是直接svn checkout出来的。两个代码在引用urllib不一样。

    不过这个有区别么?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2895 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 07:30 · PVG 15:30 · LAX 00:30 · JFK 03:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.