python2.7 - python:ImportError: No module named coockielib
大家讲道理
大家讲道理 2017-04-18 09:26:53
0
2
884

使用mac自带的python环境,python版本是2.7.10
运行后出现了如下信息:

Traceback (most recent call last):
  File "/Users/TracyW/Documents/test.py", line 3, in <module>
    import coockielib
ImportError: No module named coockielib

在终端输入easy_install cookielib

得到:

bogon:~ TracyW$ easy_install cookielib
Searching for cookielib
Reading https://pypi.python.org/simple/cookielib/
Couldn't find index page for 'cookielib' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
error: ('The read operation timed out',)

easy_install应该是没有问题的,用它下载beautifulsoup4成功了

求大神们指点一下要如何成功import cookielib?

==========================================
更新:谢谢各位,最后发现原因是把cookielib拼错了,好惭愧。。。

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

全部回复(2)
洪涛

问题点

首先, 如果你观察你安装的 log 会发现根本没有安装好, 里面有 error。

其次, 这是个 standard lib, 理论上你不需要手动去安装

第三, Python 文件里面有这一段:

Note The cookielib module has been renamed to http.cookiejar in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.

在 Python3 中改名为 http.cookiejar 了, 如果你用 Python3 的话要注意一下。

怎么 import

in Python2:

import cookielib

in Python3:

import http.cookiejar

我回答过的问题: Python-QA

PHPzhong

试试
import http.cookies
或者把生成的pyc文件删除了

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!