Flask-DebugToolbar not working with mongoDB - python-3.x

I am tying to use Flask-MongoEngine which is working fine, but I am trying to get the debug toolbar to work and when I follow the documentation I get a traceback shown below. I am able to run the normal flask debug toolbar fine but since I am using MongoDB as the database I am trying to use the flask debug toolbar with MongoDB. I know that the following line is the cause of this traceback `
app.config['DEBUG_TB_PANELS'] = ['flask_mongoengine.panels.MongoDebugPanel']
example code
from flask import Flask
from flask_debugtoolbar import DebugToolbarExtension
app = Flask(__name__)
app.config['DEBUG_TB_PANELS'] = ['flask_mongoengine.panels.MongoDebugPanel']
db = MongoEngine(app)
toolbar = DebugToolbarExtension(app)
line that causes traceback
app.config['DEBUG_TB_PANELS'] = ['flask_mongoengine.panels.MongoDebugPanel']
#traceback
Traceback (most recent call last):
File "app.py", line 27, in <module>
toolbar = DebugToolbarExtension(app)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_debugtoolbar/__init__.py", line 58, in __init__
self.init_app(app)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_debugtoolbar/__init__.py", line 72, in init_app
DebugToolbar.load_panels(app)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_debugtoolbar/toolbar.py", line 50, in load_panels
for panel_class in cls._iter_panels(app):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_debugtoolbar/toolbar.py", line 57, in _iter_panels
panel_class = cls._import_panel(app, panel_path)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_debugtoolbar/toolbar.py", line 71, in _import_panel
panel_class = import_string(path)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/werkzeug/utils.py", line 418, in import_string
__import__(import_name)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_mongoengine/panels.py", line 5, in <module>
from flask_mongoengine import operation_tracker
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_mongoengine/operation_tracker.py", line 26, in <module>
'_unpack_response': pymongo.helpers._unpack_response,
AttributeError: module 'pymongo.helpers' has no attribute '_unpack_response'

The _unpack_respone method seems to be gone or rewritten since pymongo 3.6.0.
A workaround is to install pymongo<3.6.0

Related

Data version control (DVC) commands not working ---> TypeError: public() got an unexpected keyword argument 'SEP'

All of a sudden, dvc has stopped functioning.
Any command typed fails and throws an exception.
example. dvc remote list results in -
Traceback (most recent call last):
File "/home/dev2/.local/bin/dvc", line 5, in <module>
from dvc.main import main
File "/home/dev2/.local/lib/python3.6/site-packages/dvc/main.py", line 6, in <module>
from dvc import analytics
File "/home/dev2/.local/lib/python3.6/site-packages/dvc/analytics.py", line 16, in <module>
from dvc.lock import Lock, LockError
File "/home/dev2/.local/lib/python3.6/site-packages/dvc/lock.py", line 8, in <module>
import flufl.lock
File "/home/dev2/.local/lib/python3.6/site-packages/flufl/lock/__init__.py", line 3, in <module>
from flufl.lock._lockfile import (
File "/home/dev2/.local/lib/python3.6/site-packages/flufl/lock/_lockfile.py", line 54, in <module>
public(SEP=SEP)
TypeError: public() got an unexpected keyword argument 'SEP'
Any suggestions will be of great help.

when i run my code in pycharm it is working fine but when i try to run the same code from server i am getting error

hi i am new to selenium automation .
The code which i have written is working fine and executing in both pycharm and command prompt but when i try to execute the same code from remote server i am getting the below error .
I understand it as do something with pynput but i am not able to figure out how to solve it .
If anyone know about it please help me out .
File "/home/manoj/forum-test-suite/test_forum_page/PageObject/common_methods.py", line 6, in <module>
from pynput.keyboard import Key,Controller
File "/home/manoj/newenv/lib/python3.6/site-packages/pynput/__init__.py", line 23, in <module>
from . import keyboard
File "/home/manoj/newenv/lib/python3.6/site-packages/pynput/keyboard/__init__.py", line 49, in <module>
from ._xorg import KeyCode, Key, Controller, Listener
File "/home/manoj/newenv/lib/python3.6/site-packages/pynput/keyboard/_xorg.py", line 39, in <module>
from pynput._util.xorg import (
File "/home/manoj/newenv/lib/python3.6/site-packages/pynput/_util/xorg.py", line 40, in <module>
_check()
File "/home/manoj/newenv/lib/python3.6/site-packages/pynput/_util/xorg.py", line 38, in _check
display = Xlib.display.Display()
File "/home/manoj/newenv/lib/python3.6/site-packages/Xlib/display.py", line 89, in __init__
self.display = _BaseDisplay(display)
File "/home/manoj/newenv/lib/python3.6/site-packages/Xlib/display.py", line 71, in __init__
protocol_display.Display.__init__(self, *args, **keys)
File "/home/manoj/newenv/lib/python3.6/site-packages/Xlib/protocol/display.py", line 167, in __init__
raise error.DisplayConnectionError(self.display_name, r.reason)
The issue is with respect to the pynput , you need to go to your .bashprofile and append
the pynput path , in PYTHONPATH that you have set .By doing this i was able to solve this issue.

anaconda navigator will no longer start even through cmd, won't install or update or manage environments

I'm new to django and using the anaconda cloud environment. Its been working well for 3 months plus but as of 7-24-2018 it is just stop to launch the navigator or open through cmd. I can't manage environments or install packages. Using the anaconda prompt also gives me the same error upon launching. It started when I wanted to install django-Oscar, but not having its dependencies I was forced to install the packages manually which in turn needed cytoolz that needs Microsoft Visual C++ build tools which I got to install as well but the error persists. Please help me!
Copy/Paste of CMD Traceback:
C:\Users\kaukau\Desktop>conda --version conda 4.5.4
C:\Users\kaukau\Desktop>anaconda-navigator Traceback (most recent call
last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\qtpy__init__.py", line
169, in
from PySide import version as PYSIDE_VERSION # analysis:ignore ModuleNotFoundError: No module named 'PySide'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\Scripts\anaconda-navigator-script.py", line
6, in
from anaconda_navigator.app.main import main File "C:\Users\kaukau\Anaconda3\lib\site-packages\anaconda_navigator\app\main.py",
line 22, in
from anaconda_navigator.utils.conda import is_conda_available File
"C:\Users\kaukau\Anaconda3\lib\site-packages\anaconda_navigator\utils__init__.py",
line 15, in
from qtpy.QtGui import QIcon File "C:\Users\kaukau\Anaconda3\lib\site-packages\qtpy__init__.py", line
175, in
raise PythonQtError('No Qt bindings could be found') qtpy.PythonQtError: No Qt bindings could be found
C:\Users\kaukau\Desktop>conda install qt --force Traceback (most
recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 42, in
from cytoolz.dicttoolz import merge File "C:\Users\kaukau\Anaconda3\lib\site-packages\cytoolz__init__.py",
line 1, in
from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 819, in call
return func(*args, **kwargs) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\cli\main.py", line
73, in _main
from ..base.context import context File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\base\context.py",
line 23, in
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter, File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 47, in
from .._vendor.toolz.functoolz import excepts File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda_vendor\toolz\functoolz.py",
line 501
f.name for f in reversed((self.first,) + self.funcs),
^ SyntaxError: Generator expression must be parenthesized
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 42, in
from cytoolz.dicttoolz import merge File "C:\Users\kaukau\Anaconda3\lib\site-packages\cytoolz__init__.py",
line 1, in
from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\Scripts\conda-script.py", line 10, in
sys.exit(main()) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\cli\main.py", line
113, in main
return conda_exception_handler(_main, *args) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 1112, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 822, in call
return self.handle_exception(exc_val, exc_tb) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 864, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 876, in handle_unexpected_exception
self.print_unexpected_error_report(error_report) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 932, in print_unexpected_error_report
from .base.context import context File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\base\context.py",
line 23, in
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter, File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 47, in
from .._vendor.toolz.functoolz import excepts File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda_vendor\toolz\functoolz.py",
line 501
f.name for f in reversed((self.first,) + self.funcs),
^ SyntaxError: Generator expression must be parenthesized Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 42, in
from cytoolz.dicttoolz import merge File "C:\Users\kaukau\Anaconda3\lib\site-packages\cytoolz__init__.py",
line 1, in
from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\cli\main.py", line
97, in main
from ..activate import main as activator_main File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\activate.py", line
11, in
from .base.context import ROOT_ENV_NAME, context, locate_prefix_by_name File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\base\context.py",
line 23, in
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter, File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 47, in
from .._vendor.toolz.functoolz import excepts File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda_vendor\toolz\functoolz.py",
line 501
f.name for f in reversed((self.first,) + self.funcs),
^ SyntaxError: Generator expression must be parenthesized
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 42, in
from cytoolz.dicttoolz import merge File "C:\Users\kaukau\Anaconda3\lib\site-packages\cytoolz__init__.py",
line 1, in
from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\Scripts\conda-script.py", line 10, in
sys.exit(main()) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\cli\main.py", line
110, in main
return ExceptionHandler().handle_exception(exc_val, exc_tb) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 864, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 876, in handle_unexpected_exception
self.print_unexpected_error_report(error_report) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 932, in print_unexpected_error_report
from .base.context import context File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\base\context.py",
line 23, in
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter, File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 47, in
from .._vendor.toolz.functoolz import excepts File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda_vendor\toolz\functoolz.py",
line 501
f.name for f in reversed((self.first,) + self.funcs),
^ SyntaxError: Generator expression must be parenthesized
I've just found out that I cant even use any conda commands except the : >conda --version< command only.
Please help me resolve this issue without uninstalling then reinstalling anaconda completely
Sorry to waste your time, I solved it by reinstalling anaconda completely and every project started working again....thanks to those who read it, the effort is appreciated.
It usually happen when you directly download and insall anaconda normally form its website.
Updating anaconda solved this issue for me in Manjaro and will surely work on Windows as well.
use conda update anaconda-navigator command to Update Anaconda.
If it doesn't starts, restart your pc and try to open it again.

Why am i recieving this attribute error when using the requests module?

I am trying to run this code:
import requests
import json
page = requests.get('https://www.wikipedia.org/')
But i continue to recieve this error:
AttributeError: module 'cgi' has no attribute 'FieldStorage'
This code works on one of my computers, but not the other.
Any ideas? Also, i'm not even using the cgi module, so I don't know where this is coming from.
Below is the full traceback:
Traceback (most recent call last):
File "C:/Users/Larson/AppData/Local/Programs/Python/Python36-
32/tetshjwbrifvheruiher.py", line 2, in <module>
import requests
File "C:\Users\Larson\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\requests\__init__.py", line 97, in <module>
from . import utils
File "C:\Users\Larson\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\requests\utils.py", line 11, in <module>
import cgi
File "C:/Users/Larson/AppData/Local/Programs/Python/Python36-32\cgi.py", line
2, in <module>
form = cgi.FieldStorage()
AttributeError: module 'cgi' has no attribute 'FieldStorage'

win32com module not found

I am trying to get pyttsx3 up and running on my computer. I did pip install pyttsx3 and pip install pypiwin32 I can see both of them in my python directory.
I type this code in to test it:
import pyttsx3
engine = pyttsx3.init()
engine.say("I will speak this text")
engine.runAndWait()
This is what comes out:
Traceback (most recent call last):
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3__init__.py", line 44, in init
eng = _activeEngines[driverName]
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\weakref.py", line 131, in getitem
o = self.datakey
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Danny\Desktop\python text to speech.py", line 9, in
engine = pyttsx3.init()
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3__init__.py", line 46, in init
eng = Engine(driverName, debug)
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\engine.py", line 52, in init
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\driver.py", line 77, in init
self._driver = self._module.buildDriver(weakref.proxy(self))
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 22, in buildDriver
return SAPI5Driver(proxy)
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 41, in init
self.setProperty('voice', self.getProperty('voice'))
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 83, in setProperty
self._tts.Voice = token
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\win32com\client\dynamic.py", line 549, in setattr
self.oleobj.Invoke(entry.dispid, 0, invoke_type, 0, value)
pywintypes.com_error: (-2147352573, 'Member not found.', None, None)
I tried the same thing on another computer that already had both installed, and got the same output. Any idea what is going on with the win32com? I have no experience with it and am pretty lost. Thanks.
Ok, so I found the answer looking at other problems that were related to the win32com module. Basically what you need to do is navigate to your python scripts folder (in my case: C:\Users\Danny\AppData\Local\Programs\Python\Python36\Scripts) and run pywin32_postinstall. Upon running that script, it works perfectly!
Cheers!

Resources