CoreyMSchafer / code_snippets

MIT License
10.36k stars 17.55k forks source link

TypeError: 'float' object is not callable #189

Closed Ninniachwen closed 2 years ago

Ninniachwen commented 2 years ago

after solving several other errors, I came across this rather generic one and I am at a loss on how to solve it. I upgraded the SQLAchemy version to 1.4, to avoid AttributeError: module 'time' has no attribute 'clock' then downgraded a bit again 1.3.24, to avoid the error can't set Variable.

so my recent setup is slightly different from the original SQLAlchemy==1.3.24 cffi>=1.11.5 Pillow>=5.3.0

also, I changed the config line into SQLALCHEMY_DATABASE_URI = 'sqlite:///site.db' to avoid AttributeError: 'NoneType' object has no attribute 'drivername'

However, when I start the app I now get TypeError: 'float' object is not callable

File "C:\Python\ToxoData\venv\Lib\site-packages\flask\app.py", line 2301, in __call__
return self.wsgi_app(environ, start_response)

File "C:\Python\ToxoData\venv\Lib\site-packages\flask\app.py", line 2287, in wsgi_app
response = self.handle_exception(e)

File "C:\Python\ToxoData\venv\Lib\site-packages\flask\app.py", line 1733, in handle_exception
reraise(exc_type, exc_value, tb)

File "C:\Python\ToxoData\venv\Lib\site-packages\flask\_compat.py", line 35, in reraise
raise value

File "C:\Python\ToxoData\venv\Lib\site-packages\flask\app.py", line 2284, in wsgi_app
response = self.full_dispatch_request()

File "C:\Python\ToxoData\venv\Lib\site-packages\flask\app.py", line 1807, in full_dispatch_request
rv = self.handle_user_exception(e)

File "C:\Python\ToxoData\venv\Lib\site-packages\flask\app.py", line 1710, in handle_user_exception
reraise(exc_type, exc_value, tb)

File "C:\Python\ToxoData\venv\Lib\site-packages\flask\_compat.py", line 35, in reraise
raise value

File "C:\Python\ToxoData\venv\Lib\site-packages\flask\app.py", line 1805, in full_dispatch_request
rv = self.dispatch_request()

File "C:\Python\ToxoData\venv\Lib\site-packages\flask\app.py", line 1791, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)

File "C:\Python\ToxoData\flaskblog\main\routes.py", line 11, in home
posts = Post.query.order_by(Post.date_posted.desc()).paginate(page=page, per_page=5)

File "C:\Python\ToxoData\venv\Lib\site-packages\flask_sqlalchemy\__init__.py", line 491, in paginate
items = self.limit(per_page).offset((page - 1) * per_page).all()

File "C:\Python\ToxoData\venv\Lib\site-packages\sqlalchemy\orm\query.py", line 3373, in all
return list(self)

File "C:\Python\ToxoData\venv\Lib\site-packages\sqlalchemy\orm\query.py", line 3535, in __iter__
return self._execute_and_instances(context)

File "C:\Python\ToxoData\venv\Lib\site-packages\sqlalchemy\orm\query.py", line 3560, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)

File "C:\Python\ToxoData\venv\Lib\site-packages\sqlalchemy\engine\base.py", line 1011, in execute
return meth(self, multiparams, params)

File "C:\Python\ToxoData\venv\Lib\site-packages\sqlalchemy\sql\elements.py", line 298, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)

File "C:\Python\ToxoData\venv\Lib\site-packages\sqlalchemy\engine\base.py", line 1124, in _execute_clauseelement
ret = self._execute_context(

File "C:\Python\ToxoData\venv\Lib\site-packages\sqlalchemy\engine\base.py", line 1224, in _execute_context
statement, parameters = fn(

File "C:\Python\ToxoData\venv\Lib\site-packages\sqlalchemy\events.py", line 646, in wrap_before_cursor_execute
orig_fn(

File "C:\Python\ToxoData\venv\Lib\site-packages\flask_sqlalchemy\__init__.py", line 252, in before_cursor_execute
context._query_start_time = _timer()

does anyone have any ideas?...

Ninniachwen commented 2 years ago
if sys.platform == 'win32':
    _timer = time.perf_counter    #this line may not include the () behind perf_counter....
else:
    _timer = time.time