search

Home  >  Q&A  >  body text

python2.7 - python:ImportError: No module named coockielib

使用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拼错了,好惭愧。。。

大家讲道理大家讲道理2807 days ago934

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 09:28:53

    Problem point

    First of all, if you observe the log of your installation, you will find that it is not installed at all and there are errors in it.

    Secondly, this is a standard lib. In theory, you don’t need to install it manually

    Third, there is this paragraph in the Python file:

    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.

    was renamed to http.cookiejar in Python3, please pay attention if you use Python3.

    How to import

    in Python2:

    import cookielib

    in Python3:

    import http.cookiejar

    Questions I answered: Python-QA

    reply
    0
  • PHPz

    PHPz2017-04-18 09:28:53

    Try
    import http.cookies
    or delete the generated pyc file

    reply
    0
  • Cancelreply