2017-09-27 79 views
1

我無法讓這個工作。我不斷添加模塊,並且每次都找不到新模塊。爲什麼這個代碼不能在Python3.6中工作?Python3'無法導入名稱'cached_property'

代碼:

from robobrowser import robobrowser 
from bs4 import BeautifulSoup 
import urllib2 
import cookielib 
from werkzeug import werkzeug 
from cached_property import cached_property 

cj = cookielib.CookieJar() 
br = robobrowser.Browser() 
br.set_cookiejar(cj) 
br.open("https://www.cbssports.com/login") 

br.select_form(nr=0) 
br.form['userid'] = 'steveb1164' 
br.form['password'] = '' 
br.submit() 

print(br.response().read()) 

運行:

RESTART: C:/Users/Steve/AppData/Local/Programs/Python/Python36-32/CBSlogin.py 
Traceback (most recent call last): 
    File "C:/Users/Steve/AppData/Local/Programs/Python/Python36-32/CBSlogin.py", line 1, in <module> 
    from robobrowser import robobrowser 
    File "C:\Users\Steve\AppData\Local\Programs\Python\Python36-32\lib\site-packages\robobrowser\robobrowser\__init__.py", line 3, in <module> 
    from .browser import RoboBrowser 
    File "C:\Users\Steve\AppData\Local\Programs\Python\Python36-32\lib\site-packages\robobrowser\robobrowser\browser.py", line 8, in <module> 
    from werkzeug import cached_property 
ImportError: cannot import name 'cached_property' 
+1

在當前目錄中是否有名爲'werkzeug.py'的python文件? – MSeifert

+0

你可以試試,如果只是'從werkzeug導入cached_property'行? – Joe

+0

我有站點包中的werkzeug文件夾 –

回答

0

嘗試重新安裝werkzeug包。

pip uninstall Werkzeug 
pip install Werkzeug