facert / tumblr_spider

汤不热 python 多线程爬虫

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

老白问个问题是什么原因

dxs1256 opened this issue · comments

[root@Nfp tumblr]# python tumblr.py sylar258
Traceback (most recent call last):
File "tumblr.py", line 6, in
import queue
ImportError: No module named queue

看不懂为什么

from multiprocessing import Queue as queue

commented

`[root@vultr tumblr_spider]# git diff tumblr.py
diff --git a/tumblr.py b/tumblr.py
index 4ebc2fd..b0d8ef6 100644
--- a/tumblr.py
+++ b/tumblr.py
@@ -3,7 +3,11 @@ import signal
import sys
import requests
import threading
-import queue
+is_py2 = sys.version[0] == '2'
+if is_py2:

  • import Queue as queue
    +else:
  • import queue as queue
    import time
    from bs4 import BeautifulSoup

`