gpt4 book ai didi

python - 运行 pgadmin 抛出意外错误

转载 作者:行者123 更新时间:2023-12-04 18:49:40 26 4
gpt4 key购买 nike

我已经在我的 ubuntu 20.04 机器上安装了 postgresql 和 pgadmin。
但是当我在终端中运行此命令时遇到此错误:python pgAdmin4.py

Traceback (most recent call last):
File "pgAdmin4.py", line 92, in <module>
app = create_app()
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/pgadmin4/pgadmin/__init__.py", line 350, in create_app
db_upgrade(app)
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/db_upgrade.py", line 25, in db_upgrade
flask_migrate.upgrade(migration_folder)
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/flask_migrate/__init__.py", line 95, in wrapped
f(*args, **kwargs)
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/flask_migrate/__init__.py", line 280, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/alembic/command.py",
line 298, in upgrade
script.run_env()
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/alembic/script/base.py",
line 489, in run_env
util.load_python_file(self.dir, "env.py")
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/alembic/util/pyfiles.py", line 98, in load_python_file
module = load_module_py(module_id, path)
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/alembic/util/compat.py", line 184, in load_module_py
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/../../migrations/env.py", line 94, in <module>
run_migrations_online()
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/../../migrations/env.py", line 87, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/alembic/runtime/environment.py", line 846, in run_migrations
self.get_context().run_migrations(**kw)
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/alembic/runtime/migration.py", line 520, in run_migrations
step.migration_fn(**kw)
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/pgadmin4/migrations/versions/3c1e4b6eda55_.py", line 20, in upgrade
db.engine.execute(
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2238, in execute
return connection.execute(statement, *multiparams, **params)
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1006, in execute
return self._execute_text(object_, multiparams, params)
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1175, in _execute_text
ret = self._execute_context(
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1317, in _execute_context
self._handle_dbapi_exception(
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
util.raise_(
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 178, in raise_
raise exception
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
self.dialect.do_execute(
File "/home/farhad/Public/pgadmin/pgadmin/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) duplicate column name: hostaddr
[SQL: ALTER TABLE server ADD COLUMN hostaddr TEXT(1024)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
在此之前我经常安装它,没有任何问题。
我已经用这个命令安装了 postgresql: sudo apt install postgresql postgresql-contrib然后我根据以下步骤安装了 pgadmin:
  • 运行命令sudo apt install build-essential libssl-dev libffi-dev libgmp3-dev virtualenv python3-pip libpq-dev python-dev
  • 创建一个名为 pgadmin 的目录在我系统的某个地方。
  • 使用 virtualenv创建隔离环境并运行命令virtualenv pgadmin .
  • cd pgadmin .
  • source bin/activate
  • 运行命令wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v4.23/pip/pgadmin4-4.23-py3-none-any.whl .
  • 使用 python pip 安装它:pip install pgadmin4-4.23-py3-none-any.whl
  • 创建一个名为 config_local.py 的文件在这条路上:
  • /pgadmin/pgadmin/lib/python3.8/site-packages/pgadmin4并将此内容放入其中:
    import os
    DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.pgAdmin/'))
    LOG_FILE = os.path.join(DATA_DIR, 'pgAdmin4.log')
    SQLITE_PATH = os.path.join(DATA_DIR, 'pgAdmin4.db')
    SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
    STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
    SERVER_MODE = False
  • 最后,当我通过命令 python /pgadmin/pgadmin/lib/python3.8/site-packages/pgadmin4/pgadmin4.py 运行 pgadmin 时面对那个错误。
  • 最佳答案

    该问题与 pgadmin 的 sqlite 数据库有关。
    sqlite 数据库位于 ~/.pgAdmin/pgAdmin4.db .我删除了 ~/.pgAdmin目录并重新安装 pgadmin。它已得到纠正。

    关于python - 运行 pgadmin 抛出意外错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62978611/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com