安装superset遇到的坑
阅读原文时间:2023年07月14日阅读:1

实验环境:ubuntu16.04

python环境: 3.6.7

安装参考:https://superset.incubator.apache.org/installation.html

特别提醒:

python3.6-dev 一定要安装

(venv1) root@VM-220-19-ubuntu:/data# fabmanager create-admin --app superset
Username [admin]: admin
User first name [admin]: admin
User last name [user]: admin
Email [admin@fab.org]: admin@aldwx.com
Password:
Repeat for confirmation:
Was unable to import superset Error: cannot import name '_maybe_box_datetimelike'

解决方法

卸载当前pandas版本,安装pandas==0.23.4

(venv1) root@VM-220-19-ubuntu:/data# pip3 uninstall pandas
Uninstalling pandas-0.24.2:
  Would remove:
    /data/venv1/lib/python3.6/site-packages/pandas-0.24.2.dist-info/*
    /data/venv1/lib/python3.6/site-packages/pandas/*
Proceed (y/n)? Y
  Successfully uninstalled pandas-0.24.2
(venv1) root@VM-220-19-ubuntu:/data#
(venv1) root@VM-220-19-ubuntu:/data#
(venv1) root@VM-220-19-ubuntu:/data# pip3 install pandas==0.23.4
Collecting pandas==0.23.4
  Using cached https://files.pythonhosted.org/packages/e1/d8/feeb346d41f181e83fba45224ab14a8d8af019b48af742e047f3845d8cff/pandas-0.23.4-cp36-cp36m-manylinux1_x86_64.whl
Requirement already satisfied: pytz>=2011k in ./venv1/lib/python3.6/site-packages (from pandas==0.23.4) (2018.9)
Requirement already satisfied: numpy>=1.9.0 in ./venv1/lib/python3.6/site-packages (from pandas==0.23.4) (1.16.2)
Requirement already satisfied: python-dateutil>=2.5.0 in ./venv1/lib/python3.6/site-packages (from pandas==0.23.4) (2.8.0)
Requirement already satisfied: six>=1.5 in ./venv1/lib/python3.6/site-packages (from python-dateutil>=2.5.0->pandas==0.23.4) (1.12.0)
Installing collected packages: pandas


(venv1) root@VM-220-19-ubuntu:/data# fabmanager create-admin --app superset
Username [admin]: admin
User first name [admin]: admin
User last name [user]: admin
Email [admin@fab.org]: admin@aldwx.com
Password:
Repeat for confirmation:
Recognized Database Authentications.
2019-03-18 23:14:05,535:ERROR:flask_appbuilder.security.sqla.manager:Error adding new user to database. (sqlite3.IntegrityError) UNIQUE constraint failed: ab_user.email
[SQL: INSERT INTO ab_user (first_name, last_name, username, password, active, email, last_login, login_count, fail_login_count, created_on, changed_on, created_by_fk, changed_by_fk) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]
[parameters: ('admin', 'admin', 'admin', 'pbkdf2:sha256:50000$FaQRT7OQ$67953f905b97e56de418b790a5025576a4a0d68fdb140ef0dcde9494e99ced25', 1, 'admin@aldwx.com', None, None, None, '2019-03-18 23:14:05.534844', '2019-03-18 23:14:05.534859', None, None)]
(Background on this error at: http://sqlalche.me/e/gkpj)
No user created an error occured

问题分析

报错提示唯一约束失败。因为创建的用户发生冲突

解决方法1

修改用户,指定其他用户为管理员

解决方法2

如果是新建数据库,可以重建。在此基础上如果是sqlite数据库,可以修改数据库文件名或删除数据库文件,让程序自动重建。

配置数据库的文件 /data/venv1/lib/python3.6/site-packages/superset/config.py

sqlite数据库默认在当前用户下 ~/.superset/superset.db

(venv1) root@VM-220-19-ubuntu:/data# superset db upgrade
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade bddc498dd179 -> 3dda56f1c4c6, Migrate num_period_compare and perio
INFO  [alembic.runtime.migration] Running upgrade 3dda56f1c4c6 -> 1d9e835a84f9, empty message
/data/venv1/lib/python3.6/site-packages/alembic/util/messaging.py:73: UserWarning: Skipping unsupported ALTER for cr
  warnings.warn(msg)
INFO  [alembic.runtime.migration] Running upgrade bddc498dd179 -> 4451805bbaa1, remove double percents
Traceback (most recent call last):
  File "/data/venv1/bin/superset", line 15, in <module>
    cli()
  File "/data/venv1/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/data/venv1/lib/python3.6/site-packages/flask/cli.py", line 380, in main
    return AppGroup.main(self, *args, **kwargs)
  File "/data/venv1/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/data/venv1/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/data/venv1/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/data/venv1/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/data/venv1/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/data/venv1/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/data/venv1/lib/python3.6/site-packages/flask/cli.py", line 257, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "/data/venv1/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/data/venv1/lib/python3.6/site-packages/flask_migrate/cli.py", line 134, in upgrade
    _upgrade(directory, revision, sql, tag, x_arg)
  File "/data/venv1/lib/python3.6/site-packages/flask_migrate/__init__.py", line 95, in wrapped
    f(*args, **kwargs)
  File "/data/venv1/lib/python3.6/site-packages/flask_migrate/__init__.py", line 280, in upgrade
    command.upgrade(config, revision, sql=sql, tag=tag)
  File "/data/venv1/lib/python3.6/site-packages/alembic/command.py", line 276, in upgrade
    script.run_env()
  File "/data/venv1/lib/python3.6/site-packages/alembic/script/base.py", line 475, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/data/venv1/lib/python3.6/site-packages/alembic/util/pyfiles.py", line 90, in load_python_file
    module = load_module_py(module_id, path)
  File "/data/venv1/lib/python3.6/site-packages/alembic/util/compat.py", line 156, in load_module_py
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/data/venv1/lib/python3.6/site-packages/superset/migrations/env.py", line 100, in <module>
    run_migrations_online()
  File "/data/venv1/lib/python3.6/site-packages/superset/migrations/env.py", line 93, in run_migrations_online
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File "/data/venv1/lib/python3.6/site-packages/alembic/runtime/environment.py", line 839, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/data/venv1/lib/python3.6/site-packages/alembic/runtime/migration.py", line 361, in run_migrations
    step.migration_fn(**kw)
  File "/data/venv1/lib/python3.6/site-packages/superset/migrations/versions/4451805bbaa1_remove_double_percents.py"
    replace('%%', '%')
  File "/data/venv1/lib/python3.6/site-packages/superset/migrations/versions/4451805bbaa1_remove_double_percents.py"
    .join(Table)
  File "/data/venv1/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2235, in join
    from_joinpoint=from_joinpoint,
  File "<string>", line 2, in _join
  File "/data/venv1/lib/python3.6/site-packages/sqlalchemy/orm/base.py", line 220, in generate
    fn(self, *args[1:], **kw)
  File "/data/venv1/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2414, in _join
    left, right, onclause, prop, create_aliases, outerjoin, full
  File "/data/venv1/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2437, in _join_left_to_right
    ) = self._join_determine_implicit_left_side(left, right, onclause)
  File "/data/venv1/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2568, in _join_determine_implicit_lef
    "Can't determine which FROM clause to join "
sqlalchemy.exc.InvalidRequestError: Can't determine which FROM clause to join from, there are multiple FROMS which cto help resolve the ambiguity.

解决方法

安装sqlalchemy==1.2.18

pip install sqlalchemy==1.2.18    #当时用pip安装的,结果也没问题

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章