Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python3 'Cannot import name 'cached_property'

I cannot get this to work. I keep adding modules and there's a new one not found each time. Why doesn't this code work in Python3.6?

Code:

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())

Run:

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'
like image 769
Steve Burr Avatar asked Sep 27 '17 21:09

Steve Burr


1 Answers

I got the werkzeug app running in Python 3.6 by inserting those lines before the Flask importing:

import werkzeug
werkzeug.cached_property = werkzeug.utils.cached_property
like image 105
Lucioric2000 Avatar answered Sep 23 '22 13:09

Lucioric2000