When I create database from pgadmin 4, it always show error popup: Error saving properties.
My computer info:
Linux Mint 18.3
pgAdmin 4 2.1 from https://wiki.postgresql.org/wiki/Apt
Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609]
My error in pgadmin4.log:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 180, in run_wsgi
execute(self.server.app)
File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 168, in execute
application_iter = app(environ, start_response)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/lib/python3/dist-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/lib/python3/dist-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/lib/python3/dist-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/lib/python3/dist-packages/flask/views.py", line 84, in view
return self.dispatch_request(*args, **kwargs)
File "/usr/share/pgadmin4/web/pgadmin/browser/utils.py", line 242, in dispatch_request
return method(*args, **kwargs)
File "/usr/share/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/__init__.py", line 157, in wrapped
return f(self, *args, **kwargs)
File "/usr/share/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/__init__.py", line 489, in create
data=data, conn=self.conn
File "/usr/lib/python3/dist-packages/flask/templating.py", line 128, in render_template
context, ctx.app)
File "/usr/lib/python3/dist-packages/flask/templating.py", line 110, in _render
rv = template.render(context)
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 989, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/usr/share/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/create.sql", line 10, in top-level template code
ENCODING = {{ data.encoding|qtLiteral }}{% endif %}{% if data.datcollate %}
File "/usr/share/pgadmin4/web/pgadmin/utils/driver/psycopg2/__init__.py", line 2079, in qtLiteral
adapted.encoding = 'utf8'
AttributeError: attribute 'encoding' of 'psycopg2.extensions.QuotedString' objects is not writable
Commenting out two lines in python code resolves the issue:
sudo sed -i '2078,2079 s/^[^#]/#/'
/usr/share/pgadmin4/web/pgadmin/utils/driver/psycopg2/__init__.py
The lines are:
if hasattr(adapted, 'encoding'):
adapted.encoding = 'utf8'
Probably you need psycopg > 2.6.2. See https://github.com/psycopg/psycopg2/issues/331
Install the python-psycopg2 complement, in ubuntu:
sudo apt-get install python-psycopg2
That Works for me !
Regards !
Related
I have setup superset as per the documentation from the official site. I am able to create charts and dashboards from the Explore option in SQLLab, but getting the following error when I try to create a chart from New + button on the home page.
Python version: 3.6.3
Superset version : 0.38.0
Breaking URL : /chart/add
File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib64/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib64/python3.6/site-packages/flask_appbuilder/security/decorators.py", line 109, in wraps
return f(self, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/superset/views/chart/views.py", line 71, in add
"superset/add_slice.html", bootstrap_data=json.dumps(payload)
File "/usr/lib64/python3.6/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib64/python3.6/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib64/python3.6/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib64/python3.6/json/encoder.py", line 180, in default
o.__class__.__name__)
TypeError: Object of type 'function' is not JSON serializable
I am new to python. I am following a tutorial series tk make a website using flask. But when i fill up the contact form and then click on send i get this error
ModuleNotFoundError: No module named 'MySQLdb'
Traceback (most recent call last)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\util\_collections.py", line 1020, in __call__
return self.registry[key]
During handling of the above exception, another exception occurred:
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\acer\PycharmProjects\webdev.flask\first.1.py", line 46, in contact
db.session.add(entry)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\orm\scoping.py", line 163, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\util\_collections.py", line 1022, in __call__
return self.registry.setdefault(key, self.createfunc())
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\orm\session.py", line 3286, in __call__
return self.class_(**local_kw)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_sqlalchemy\__init__.py", line 138, in __init__
bind = options.pop('bind', None) or db.engine
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_sqlalchemy\__init__.py", line 943, in engine
return self.get_engine()
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_sqlalchemy\__init__.py", line 962, in get_engine
return connector.get_engine()
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_sqlalchemy\__init__.py", line 556, in get_engine
self._engine = rv = self._sa.create_engine(sa_url, options)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_sqlalchemy\__init__.py", line 972, in create_engine
return sqlalchemy.create_engine(sa_url, **engine_opts)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\engine\__init__.py", line 500, in create_engine
return strategy.create(*args, **kwargs)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\engine\strategies.py", line 87, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\dialects\mysql\mysqldb.py", line 118, in dbapi
return __import__("MySQLdb")
ModuleNotFoundError: No module named 'MySQLdb'
I tried to install mysqlient but it also gives ' cant build the wheel ' error.
I am using python 3.8
How to solve this issue?
if you use pycharm then file - > settings -> interpreter - > + (right). there you install wheel and mysql client (not always the latest version works)
if manually I assume that you are using a virtual environment, then you need to activate it and it already has "pip install wheel" also mysqlclient
I have attempted to make a Full-Feature Web App, and this includes using WTForms as the databasing resource, I am stumped at this error,
jinja2.exceptions.UndefinedError: 'wtforms.fields.core.StringField object' has no attribute 'username'
Traceback (most recent call last):
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/flask/app.py", line 2328, in __call__
return self.wsgi_app(environ, start_response)
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/flask/app.py", line 2314, in wsgi_app
response = self.handle_exception(e)
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/flask/app.py", line 1760, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/flask/_compat.py", line 36, in reraise
raise value
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/flask/app.py", line 2311, in wsgi_app
response = self.full_dispatch_request()
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/flask/app.py", line 1834, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/flask/app.py", line 1737, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/flask/_compat.py", line 36, in reraise
raise value
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/flask/app.py", line 1832, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/flask/app.py", line 1818, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users/lkendon/flaskblog/flaskblog.py", line 36, in register
return render_template('register.html', title='Register', form=form)
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/flask/templating.py", line 135, in render_template
context, ctx.app)
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/flask/templating.py", line 117, in _render
rv = template.render(context)
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Users/lkendon/flaskblog/venv/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/Users/lkendon/flaskblog/templates/register.html", line 1, in top-level template code
{% extends "layout.html" %}
File "/Users/lkendon/flaskblog/templates/layout.html", line 41, in top-level template code
{% block content %}{% endblock %}
File "/Users/lkendon/flaskblog/templates/register.html", line 10, in block "content"
{{form.username.username(class="form-control form-control-lg")}}
jinja2.exceptions.UndefinedError: 'wtforms.fields.core.StringField object' has no attribute 'username'
What on earth is the issue here, I was following a tutorial and i have the same details inputted through the provided snippets.
Looking at the traceback, you're calling {{form.username.username(... which should be {{form.username(...
I am using gridfs to store and get files from my MongoDB database
fs = gridfs.GridFS(MongoClient('mongodb://username:password#XX.XX.XX.XXX:27017/').mydb)
and to get a file I am using
file = fs.get_last_version(file_name).read()
On this line I get Authentication Failed exception.
Traceback (most recent call last):
File "C:\Python36\lib\site-packages\flask\app.py", line 1997, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Python36\lib\site-packages\flask\app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "C:\Python36\lib\site-packages\flask\app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Python36\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "C:\Python36\lib\site-packages\flask\app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "C:\Python36\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Python36\lib\site-packages\flask\app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Python36\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "C:\Python36\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Python36\lib\site-packages\flask\app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "D:\git\EEG\ABM\BLabPythonService\app.py", line 1039, in start_processing
sys.stderr.flush()
File "D:\git\EEG\ABM\BLabPythonService\process_studies.py", line 271, in start_processing
overlay_artifacts(study)
File "D:\git\EEG\ABM\BLabPythonService\process_studies.py", line 49, in overlay_artifacts
edf_file = fs.get_last_version(file_name).read()
File "C:\Python36\lib\site-packages\gridfs\__init__.py", line 200, in get_last_version
return self.get_version(filename=filename, **kwargs)
File "C:\Python36\lib\site-packages\gridfs\__init__.py", line 184, in get_version
grid_file = next(cursor)
File "C:\Python36\lib\site-packages\pymongo\cursor.py", line 1132, in next
if len(self.__data) or self._refresh():
File "C:\Python36\lib\site-packages\pymongo\cursor.py", line 1055, in _refresh
self.__collation))
File "C:\Python36\lib\site-packages\pymongo\cursor.py", line 892, in __send_message
**kwargs)
File "C:\Python36\lib\site-packages\pymongo\mongo_client.py", line 950, in _send_message_with_response
exhaust)
File "C:\Python36\lib\site-packages\pymongo\mongo_client.py", line 961, in _reset_on_error
return func(*args, **kwargs)
File "C:\Python36\lib\site-packages\pymongo\server.py", line 99, in send_message_with_response
with self.get_socket(all_credentials, exhaust) as sock_info:
File "C:\Python36\lib\contextlib.py", line 81, in __enter__
return next(self.gen)
File "C:\Python36\lib\site-packages\pymongo\server.py", line 168, in get_socket
with self.pool.get_socket(all_credentials, checkout) as sock_info:
File "C:\Python36\lib\contextlib.py", line 81, in __enter__
return next(self.gen)
File "C:\Python36\lib\site-packages\pymongo\pool.py", line 852, in get_socket
sock_info.check_auth(all_credentials)
File "C:\Python36\lib\site-packages\pymongo\pool.py", line 570, in check_auth
auth.authenticate(credentials, self)
File "C:\Python36\lib\site-packages\pymongo\auth.py", line 486, in authenticate
auth_func(credentials, sock_info)
File "C:\Python36\lib\site-packages\pymongo\auth.py", line 466, in _authenticate_default
return _authenticate_scram_sha1(credentials, sock_info)
File "C:\Python36\lib\site-packages\pymongo\auth.py", line 237, in _authenticate_scram_sha1
res = sock_info.command(source, cmd)
File "C:\Python36\lib\site-packages\pymongo\pool.py", line 477, in command
collation=collation)
File "C:\Python36\lib\site-packages\pymongo\network.py", line 116, in command
parse_write_concern_error=parse_write_concern_error)
File "C:\Python36\lib\site-packages\pymongo\helpers.py", line 210, in _check_command_response
raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: Authentication failed.
Everything worked fine when my mongo database didnt have authentication.
Other use of database is working fine. I have this python service that is connecting to database using flask_pymogno and a c# application that is also connecting to database using c#, and all connections are with the same credentials.
Solved it. The problem was actually in my password witch contained '+' character. It is a reserved URI character. Fixed it by replacing '+' with '%2B' and it now works.
Reference:
https://en.wikipedia.org/wiki/Percent-encoding
I'm trying to create a small flask application using the Enferno framework, but when I try to register a user I get an error that seems to be generated by the passlib library. I can't understand if it's something I did or if it is an error in the library itself.
Here's the full traceback:
Traceback (most recent call last):
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask_debugtoolbar/__init__.py", line 125, in dispatch_request
return view_func(**req.view_args)
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask_security/decorators.py", line 205, in wrapper
return f(*args, **kwargs)
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask_security/views.py", line 117, in register
user = register_user(**form.to_dict())
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask_security/registerable.py", line 28, in register_user
kwargs['password'] = encrypt_password(kwargs['password'])
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask_security/utils.py", line 151, in encrypt_password
return _pwd_context.encrypt(signed)
File "/home/el3k0n/.local/lib/python3.4/site-packages/passlib/context.py", line 2495, in encrypt
return self._get_record(scheme, category).encrypt(secret, **kwds)
File "/home/el3k0n/.local/lib/python3.4/site-packages/passlib/utils/handlers.py", line 558, in encrypt
self.checksum = self._calc_checksum(secret)
File "/home/el3k0n/.local/lib/python3.4/site-packages/passlib/handlers/bcrypt.py", line 285, in _calc_checksum
return self._calc_checksum_backend(secret)
File "/home/el3k0n/.local/lib/python3.4/site-packages/passlib/utils/handlers.py", line 1458, in _calc_checksum_backend
return self._calc_checksum_backend(secret)
File "/home/el3k0n/.local/lib/python3.4/site-packages/passlib/handlers/bcrypt.py", line 333, in _calc_checksum_pybcrypt
hash = _bcrypt.hashpw(secret, config)
TypeError: hashpw() argument 1 must be str, not bytes
I just ran into this. Turns out, I had installed both bcrypt and python-bcrypt in my virtualenv. passlib.hash.bcrypt has a check to see which version on bcrypt is present. By removing the python-bcrypt, I was able to cease this error from being thrown.