$ superset --version
Python 3.9.12
Flask 2.2.3
Werkzeug 2.2.3
使用 Miniconda3-latest-Linux-x86_64 脚本完成 conda包管理器的安装
命令 | 说明 |
---|---|
conda create -n env_name -y | 创建一个新的环境 |
conda activate env_name | 激活一个环境 或 切换 env_name环境 |
conda deactivate | 停用当前活动的环境,退出当前环境 |
conda env list | 列出所有可用的环境 |
conda info --envs | 查看所有环境 |
conda config --show-sources | 查看 conda 的 config文件 .condarc 路径 |
conda env export | 导出环境到一个YAML文件中 |
conda env create -y | 通过YAML文件创建一个新的环境 |
conda env remove -y | 删除一个环境 |
conda remove -n env_name --all -y | 删除一个环境(all版本) |
conda list | 列出当前活动环境中安装的所有软件包 |
conda list | findstr “软件名/关键字” | 列出当前活动环境中含有 软件名/关键字 的安装软件包 |
conda install | 安装指定的软件包 |
conda uninstall | 卸载指定的软件包 |
conda update | 更新当前环境中的软件包 |
conda search | 在conda仓库中搜索软件包 |
conda info | 显示关于conda安装的信息 |
conda config | 管理conda的配置设置 |
conda config --set auto_activate_base false | 禁止自动激活/切换为 默认base环境 |
conda config --add envs_dirs F:/Anaconda3/envs | 设置.envs目录的位置 |
conda config --set pkgs_dirs F:/Anaconda3/envs | 更改.cache目录的位置 |
conda config --set remote_read_timeout_secs 1800.0 | 设置下载超时限制 |
conda config --remove channels defaults | 删除指定镜像源(其他源替换defaults即可) |
conda clean -i -y | 清理conda索引缓存和未使用的软件包 |
conda build | 构建软件包 |
conda develop | 在开发模式下安装软件包 |
conda skeleton | 为不在conda仓库中的软件包生成元数据 |
conda convert | 转换软件包到不同的平台或版本 |
conda inspect | 检查一个包的详细信息 |
conda package | 构建和管理conda软件包 |
conda bundle | 将环境打包成一个文件,以便在其他机器上进行复制和安装 |
conda server | 启动一个本地的conda软件包服务器 |
conda skeleton pypi | 为PyPI上的软件包生成conda构建脚本 |
conda skeleton cran | 为CRAN上的软件包生成conda构建脚本 |
conda skeleton feedstock | 为给定的feedstock生成conda构建脚本 |
conda env config | 管理环境配置 |
conda init | 初始化shell以使用conda |
conda run | 在环境中运行命令 |
conda develop | 在开发模式下安装软件包 |
conda lock | 锁定环境的软件包版本 |
conda unlock | 解锁环境的软件包版本 |
conda history | 显示环境的操作历史记录 |
# 添加阿里云镜像源
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/main/
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/free/
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/msys2/
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/r/
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/conda-forge/
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/msys2/
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/bioconda/
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/menpo/
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/pytorch/
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/simpleitk/
conda config --set show_channel_urls yes
# 北京外国语大学镜像源
conda config --add channels http://mirrors.bfsu.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.bfsu.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.bfsu.edu.cn/anaconda/pkgs/msys2/
conda config --add channels http://mirrors.bfsu.edu.cn/anaconda/pkgs/r/
conda config --add channels http://mirrors.bfsu.edu.cn/anaconda/pkgs/mro/
conda config --add channels http://mirrors.bfsu.edu.cn/anaconda/pkgs/pro/
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/conda-forge/
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/msys2/
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/bioconda/
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/menpo/
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/pytorch/
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/simpleitk/
conda config --set show_channel_urls yes
# 添加清华镜像源
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes
本地config文件配置方式
查看.condarc配置文件路径
conda config --show-sources
2. 添加如下内容 ```properties envs_dirs: - E:/anaconda3/envs remote_read_timeout_secs: 1800.0 auto_activate_base: false channels: - defaults show_channel_urls: true default_channels: - http://mirrors.aliyun.com/anaconda/pkgs/main - http://mirrors.aliyun.com/anaconda/pkgs/r - http://mirrors.aliyun.com/anaconda/pkgs/msys2 custom_channels: conda-forge: http://mirrors.aliyun.com/anaconda/cloud msys2: http://mirrors.aliyun.com/anaconda/cloud bioconda: http://mirrors.aliyun.com/anaconda/cloud menpo: http://mirrors.aliyun.com/anaconda/cloud pytorch: http://mirrors.aliyun.com/anaconda/cloud simpleitk: http://mirrors.aliyun.com/anaconda/cloud
上述内容解释
可以使用命令方式自动写入,也可以手动修改配置文件。效果相同
conda create -n python39 python=3.9 -y
# 查看是否创建好环境
conda info --envs
conda activate python39
命令 | 描述 |
---|---|
pip install 包名 | 安装包 |
pip install 包名==版本号 | 指定版本的安装包 |
pip install 包名 -i 镜像源 | 从国内镜像源下载,速度更快【清华源:https://pypi.tuna.tsinghua.edu.cn/simple 阿里源:https://mirrors.aliyun.com/pypi/ 豆瓣源:】 |
download | 下载包 |
uninstall | 卸载包 |
freeze | 输出当前环境的所有包及其版本号 |
pip list | 列出所有已安装包 |
wheel | 构建 wheel 文件 |
hash | 输出安装包的哈希值 |
check | 验证安装包是否完整 |
completion | 生成 shell 自动补全代码 |
pip show 包名 | 显示安装的包的详细信息 |
pip search 包名 | 搜索 PyPI 库 |
sudo yum install -y gcc gcc-c++ libffi-devel python-devel python-pip python-wheel python-setuptools openssl-devel cyrus-sasl-devel openldap-devel
pip install --upgrade setuptools pip --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple
pip install apache-superset --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple
元数据库修改为MySQL数据库 [详见文章大数据——Superset安装篇(二)Python3.8环境+MySQL元数据库]
# flask是一个python web框架,superset使用的就是flask
export FLASK_APP=superset
# superset 建库建表
superset db upgrade
报错1
Traceback (most recent call last): File "/opt/module/miniconda3/envs/python39/bin/superset", line 5, in <module> from superset.cli.main import superset File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/superset/__init__.py", line 21, in <module> from superset.app import create_app File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/superset/app.py", line 23, in <module> from superset.initialization import SupersetAppInitializer File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/superset/initialization/__init__.py", line 33, in <module> from superset.extensions import ( File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/superset/extensions/__init__.py", line 32, in <module> from superset.utils.cache_manager import CacheManager File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/superset/utils/cache_manager.py", line 24, in <module> from superset.utils.core import DatasourceType File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/superset/utils/core.py", line 76, in <module> from cryptography.hazmat.backends.openssl.x509 import _Certificate ModuleNotFoundError: No module named 'cryptography.hazmat.backends.openssl.x509'
解决方案
pip install cryptography==3.3.2 --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple
报错2
Traceback (most recent call last): File "/opt/module/miniconda3/envs/python39/bin/superset", line 8, in <module> sys.exit(superset()) File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/click/core.py", line 1130, in __call__ return self.main(*args, **kwargs) File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/click/core.py", line 1651, in invoke cmd_name, cmd, args = self.resolve_command(ctx, args) File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/click/core.py", line 1698, in resolve_command cmd = self.get_command(ctx, cmd_name) File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/flask/cli.py", line 578, in get_command app = info.load_app() File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/flask/cli.py", line 308, in load_app app = locate_app(import_name, name) File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/flask/cli.py", line 235, in locate_app return find_best_app(module) File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/flask/cli.py", line 63, in find_best_app app = app_factory() File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/superset/app.py", line 44, in create_app raise ex File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/superset/app.py", line 37, in create_app app_initializer.init_app() File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/superset/initialization/__init__.py", line 460, in init_app self.init_app_in_ctx() File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/superset/initialization/__init__.py", line 410, in init_app_in_ctx self.configure_data_sources() File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/superset/initialization/__init__.py", line 476, in configure_data_sources ConnectorRegistry.register_sources(module_datasource_map) File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/superset/connectors/connector_registry.py", line 42, in register_sources module_obj = __import__(module_name, fromlist=class_names) File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/superset/connectors/sqla/__init__.py", line 17, in <module> from . import models, views File "/opt/module/miniconda3/envs/python39/lib/python3.9/site-packages/superset/connectors/sqla/views.py", line 28, in <module> from wtforms.ext.sqlalchemy.fields import QuerySelectField ModuleNotFoundError: No module named 'wtforms.ext'
解决方案
# 这个是因为WTForms 3.0的版本去掉了ext,需要降低WTForms的版本到2.3.3 python -m pip uninstall -y WTForms python -m pip install WTForms==2.3.3
重新执行初始化命令,即可完成初始化
superset db upgrade
export FLASK_APP=superset
superset fab create-admin
# 用户名和密码必须输入,其他直接回车跳过
> User:hadoop
> Password:hadoop
superset init
# gunicorn是一个Python Web Server,可以和java中的TomCat类比
pip install gunicorn --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple
gunicorn --workers 5 --timeout 120 --bind 你安装superset的主机IP:8787 "superset.app:create_app()" --daemon
## 参数说明:
# --workers:指定进程个数
# --timeout:worker进程超时时间,超时会自动重启
# --bind:绑定本机地址,即为Superset访问地址
# --daemon:后台运行
http://你安装superset的主机IP:8787