当我从pgadmin 4创建数据库时,它总是显示错误弹出:保存属性时出错。
我的电脑资讯:
我在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
答案 0 :(得分:1)
在python代码中注释掉两行解决了这个问题:
sudo sed -i '2078,2079 s/^[^#]/#/'
/usr/share/pgadmin4/web/pgadmin/utils/driver/psycopg2/__init__.py
这些行是:
if hasattr(adapted, 'encoding'):
adapted.encoding = 'utf8'
答案 1 :(得分:0)
可能你需要psycopg> 2.6.2。见https://github.com/psycopg/psycopg2/issues/331
答案 2 :(得分:0)
在ubuntu中安装python-psycopg2补码:
sudo apt-get install python-psycopg2
这对我有用!
问候!