suchen

Heim  >  Fragen und Antworten  >  Hauptteil

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

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

1

2

3

4

<code>Traceback (most recent call last):

  File "/Users/TracyW/Documents/test.py", line 3, in <module>

    import coockielib

ImportError: No module named coockielib</code>

在终端输入easy_install cookielib

得到:

1

2

3

4

5

6

7

8

<code>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',)

</code>

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

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

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

大家讲道理大家讲道理2884 Tage vor979

Antworte allen(2)Ich werde antworten

  • PHP中文网

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

    問題點

    首先, 如果你觀察你安裝的 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:

    1

    <code class="python">import cookielib</code>

    in Python3:

    1

    <code class="python">import http.cookiejar</code>


    我回答過的問題: Python-QA

    Antwort
    0
  • PHPz

    PHPz2017-04-18 09:28:53

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

    Antwort
    0
  • StornierenAntwort