Anaconda 安装和配置

1. Anaconda 安装

Anaconda说明及安装过程Anaconda详细安装使用教程

Anaconda环境变量配置配置环境变量

2. Anaconda和Pip源修改

  • Anaconda源修改:打开Anaconda Prompt后,输入以下代码。

    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    conda config --set show_channel_urls yes
  • Pip源修改:在本地User用户目录新建pip目录,然后新建pip.ini文件,编辑如下代码后保存。
    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple

3. Anaconda常用命令

3.1 模块迁移

  • 当前环境安装的所有模块信息导出到名为requirements.txt文件中,该文件存放在当前用户目录下

    pip freeze > requirements.txt
  • 新环境中根据requirements.txt文件来安装模块。
    pip install -r C:\Users\XXX\requirements.txt

3.2 环境创建、激活和退出

  • 创建环境

    conda create -n env_name package_name=version
  • 激活环境

    (base) C:\Users\Administrator>activate superset

    (superset) C:\Users\Administrator>

  • 列出环境
    (base) C:\Users\Administrator>conda env list
    # conda environments:
    #
    base * D:\ProSoftwares\Python\Anaconda3
    python36 D:\ProSoftwares\Python\Anaconda3\envs\python36
    superset D:\ProSoftwares\Python\Anaconda3\envs\superset
  • 退出环境
    (superset) C:\Users\Administrator>conda deactivate
    
    (base) C:\Users\Administrator>

3.3 克隆环境

使用该方法,可以重命名环境:

(base) C:\Users\Administrator>conda create -n analysis --clone python36

然后删除原来的环境即可:

(base) C:\Users\Administrator>conda remove -n python36 --all

4. Anaconda安装superset环境(在线)

4.1 创建隔离环境

(base) C:\Users\Administrator>conda activate -n superset python==3.6

创建一个隔离环境,防止和其它环境的包发生冲突。

4.2 安装VC++需求文件

进入superset环境后,尝试用pip install superset命令直接安装,最后提示Failed to build superset python-geohash错误,缺少编译环境,并提示下载:

error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

上述下载地址失效,使用VC++14.0安装教程进行安装。安装完成后,重新使用pip install superset命令安装superset,则可正常安装:

Successfully installed cchardet-2.1.4 et-xmlfile-1.0.1 ijson-2.3 jdcal-1.4.1 jsonlines-1.2.0 linear-tsv-1.1.0 openpyxl-2.4.11 pure-sasl-0.6.1 python-geohash-0.8.5 rfc3986-1.3.1 simplejson-3.16.0 sqlalchemy-utils-0.33.11 sqlparse-0.3.0 superset-0.28.1 tableschema-1.4.1 tabulator-1.20.0 thrift-0.11.0 thrift-sasl-0.3.0 unicodecsv-0.14.1 unidecode-1.0.23 xlrd-1.2.0

4.3 配置superset

  • 创建superset管理员账号

    (superset) C:\Users\Administrator>fabmanager create-admin --app superset
    fabmanager is going to be deprecated in 2.2.X, you can use the same commands on the improved 'flask fab <command>'
    Username [admin]: admin
    User first name [admin]: Strive
    User last name [user]: Py
    Email [admin@fab.org]: strive@qq.com
    Password:
    Repeat for confirmation:
    Was unable to import superset Error: cannot import name '_maybe_box_datetimelike'

    出现Was unable to import superset Error: cannot import name '_maybe_box_datetimelike'错误,原因是pandas版本(0.24.2)太高,卸载重装0.23.4版本:

    pip uninstall pandas
    
    pip install pandas==0.23.4

    再进行管理员账号创建:

    (superset) C:\Users\Administrator>fabmanager create-admin --app superset
    fabmanager is going to be deprecated in 2.2.X, you can use the same commands on the improved 'flask fab <command>'
    Username [admin]: admin
    User first name [admin]: Strive
    User last name [user]: Py
    Email [admin@fab.org]: strive@qq.com
    Password:
    Repeat for confirmation:
    Recognized Database Authentications.
    Admin User admin created.
  • 初始化数据库需要使用python superset命令,该命令需要进入superset包的bin目录(D:\ProSoftwares\Python\Anaconda3\envs\superset\Lib\site-packages\superset\bin)下执行:

    (superset) D:\ProSoftwares\Python\Anaconda3\envs\superset\Lib\site-packages\superset\bin>python superset
    Usage: superset [OPTIONS] COMMAND [ARGS]... This is a management script for the superset application. Options:
    --version Show the flask version
    --help Show this message and exit. Commands:
    db Perform database migrations.
    export_dashboards Export dashboards to JSON
    export_datasource_schema Export datasource YAML schema to stdout
    export_datasources Export datasources to YAML
    fab FAB flask group commands
    flower Runs a Celery Flower web server Celery Flower...
    import_dashboards Import dashboards from JSON
    import_datasources Import datasources from YAML
    init Inits the Superset application
    load_examples Loads a set of Slices and Dashboards and a...
    load_test_users Loads admin, alpha, and gamma user for...
    refresh_druid Refresh druid datasources
    run Runs a development server.
    runserver Starts a Superset web server.
    shell Runs a shell in the app context.
    update_datasources_cache Refresh sqllab datasources cache
    version Prints the current version number
    worker Starts a Superset worker for async SQL query...
  • 使用python superset db upgrade命令更新数据库,出现sqlalchemy.exc.InvalidRequestError: Can't determine which FROM clause to join from, there are multiple FROMS which can  join to this entity. Try adding an explicit ON clause to help resolve the ambiguity.错误,原因是sqlalchemy包版(1.3.3)本太高,卸载重装1.2.0版本,就可以成功进行数据库更新操作。
  • 使用python superset load_examples命令加载样例模板。
  • 使用python superset init命令初始化用户角色和权限。
  • 使用python superset runserver 命令启动服务报错,原因是superset使用gunicorn作为应用程序服务器,而gunicorn不支持windows,命令行中添加-d,使用development web server运行。最终运行命令为:python superset runserver -d

最后在浏览器中访问:localhost:8088就可以打开superset登录页面。

4.4 Superset数据库查询报错

因为superset是为Linux和Mac服务的,Windows下缺失某些系统依赖包,所以进行数据库查询时,会提示'Module 'signal' has no attribute 'SIGALRM',并且查询不到数据,解决办法是修改superset安装目录下的utils.py(D:\ProSoftwares\Python\Anaconda3\envs\superset\Lib\site-packages\superset\utils.py)文件中关于signal提示的代码。用文本编辑器打开utils.py,找到如下代码:

    def __enter__(self):
try:
signal.signal(signal.SIGALRM, self.handle_timeout)
signal.alarm(self.seconds)
except ValueError as e:
logging.warning("timeout can't be used in the current context")
logging.exception(e) def __exit__(self, type, value, traceback):
try:
signal.alarm(0)
except ValueError as e:
logging.warning("timeout can't be used in the current context")
logging.exception(e)

然后将代码修改为:

    def __enter__(self):
try:
# signal.signal(signal.SIGALRM, self.handle_timeout)
# signal.alarm(self.seconds)
pass
except ValueError as e:
logging.warning("timeout can't be used in the current context")
logging.exception(e) def __exit__(self, type, value, traceback):
try:
# signal.alarm(0)
pass
except ValueError as e:
logging.warning("timeout can't be used in the current context")
logging.exception(e)

然后刷新superset即可。

5 Anaconda安装Superset环境(离线)

由于在线安装出现的问题太多,所以采取离线手动安装的方式。

5.1 使用Pip安装依赖包

在Github源码中找到依赖包文件requirements.txt

然后使用Pip安装依赖包:

pip install -r C:\Users\XXX\requirements.txt

如果中途发生版本不匹配问题,修改对应包版本再继续安装即可。

5.2 使用Pip安装Superset离线包

在官网下载superset-0.34.0安装包

然后使用Pip安装superset包:

pip install C:\Users\XXX\apache-superset-0.34.0.tar.gz

5.3 配置Superset

基本参考在线安装,需要注意:

  • 设置用户名时不能设置admin,会提示唯一字段重复的sql错误。
  • 启动服务时,在bin目录内使用命令python superset run即可。

5.4 Superset数据库查询报错

因为superset是为Linux和Mac服务的,Windows下缺失某些系统依赖包,所以进行数据库查询时,会提示'Module 'signal' has no attribute 'SIGALRM',并且查询不到数据,解决办法是修改superset安装目录下的core.py(D:\Prosoftwares\Python\Anaconda3\envs\superset\Lib\site-packages\superset\utils\core.py)中关于signal提示的代码(579行),按照4.4修改后,重启服务即可。

6 参考资料

Anaconda 安装和配置的更多相关文章

  1. 面向的phthon2+3 的场景,Anaconda 安装+环境配置+管理

    standard procedure in pyCharm for creating environment when Anaconda installed Create a conda env vi ...

  2. Anaconda 安装后配置环境变量

    Anaconda 安装后在 cmd 中运算 python 无效, 是环境变量没有生效.正常安装需要有三个,配置好就行. D:\xwapp\ProgramData\Anaconda3 D:\xwapp\ ...

  3. Anaconda安装及配置

    简介 Anaconda(官方网站)指的是一个开源的Python发行版本,可以便捷获取包且对包能够进行管理,同时对环境可以统一管理的发行版本.Anaconda包含了conda.Python在内的超过18 ...

  4. Python科学计算的瑞士军刀——Anaconda 安装与配置

    Introduce Python是一种强大的编程语言.其提供了非常多用于科学计算的模块,常见的包含numpy.scipy和matplotlib.要利用Python进行科学计算.就须要一一安装所需的模块 ...

  5. Pycharm+Anaconda安装及配置

    Pycharm是一款功能非常强大的IDE,配合Anaconda使用会非常的方便. 在安装Pycharm之前,我们的电脑上已经安装了Anaconda. 我们从官网下载Pycharm社区版.(https: ...

  6. anaconda安装和配置和基本使用

    conda是个商业化公司,所以没有授权不能随便建立其镜像.虽说说的是发邮件询问基本上就能够拿到授权,然而现实是国内的各大开源镜像站都拿不到. 这个事情最近有进展了. 清华大学的镜像源已经拿到授权了 ( ...

  7. 从零开始安装搭建win10与ubuntu20.04双系统开发环境——集安装、配置、软件、美化、常见问题等于一体的——超详细教程

    目录 **前言 ** 关于系统安装配置与软件安装 一.Win10安装ubuntu20.04双系统 1.按照自己的需求分区 2.配置软件镜像源 软件包管理工具介绍 更换APT源--使用国内镜像 3.解决 ...

  8. Ubuntu环境下Anaconda安装TensorFlow并配置Jupyter远程访问

    本文主要讲解在Ubuntu系统中,如何在Anaconda下安装TensorFlow以及配置Jupyter Notebook远程访问的过程. 在官方文档中提到,TensorFlow的安装主要有以下五种形 ...

  9. Windows中Anaconda,Tensorflow 和 Pycharm的安装和配置

    Anaconda完全入门指南 https://www.jianshu.com/p/eaee1fadc1e9                 [安装不要按此条链接进行] Windows中 Anacond ...

随机推荐

  1. flv 解封装

    #include <stdio.h> #include <stdlib.h> #include <string.h> #define DEBUG_INFO type ...

  2. Hive使用druid做连接池代码实现

    配置文档 hive_jdbc_url=jdbc:hive2://192.168.0.22:10000/default hive.dbname=xxxxx hive_jdbc_username=root ...

  3. 一行代码搞定 FTP 服务

    环境搭建: python windows/linux pip install pyftpdlib (安装失败请到这里下载:https://pypi.python.org/pypi/pyftpdlib/ ...

  4. PHP编译安装系列

    徐亮伟, 江湖人称标杆徐.多年互联网运维工作经验,曾负责过大规模集群架构自动化运维管理工作.擅长Web集群架构与自动化运维,曾负责国内某大型电商运维工作. 个人博客"徐亮伟架构师之路&quo ...

  5. clutter recoder

    cin >> ch; cin.get(ch);区别读取输入是否忽略空格.制表等; char ch; ; cout << "Enter characters;enter ...

  6. 基于Tesseract的身份证识别Android端应用

    以开源的Tesseract为基础,做了一个身份证识别的app. 图片资源是百度找的,而且手机对着电脑屏幕拍照,拍出很多花纹,影响比较大,所以误差不小,实测对着自己身份证拍照会好很多. 效果图: 1.拍 ...

  7. [转] 实现winfrom进度条及进度信息提示,winfrom程序假死处理

    china_xuhua 原文地址 1.方法一:使用线程 功能描述:在用c#做WinFrom开发的过程中.我们经常需要用到进度条(ProgressBar)用于显示进度信息.这时候我们可能就需要用到多线 ...

  8. arcserver 跨域问题

    http://resources.arcgis.com/en/help/rest/apiref/config.html#jcrossOriginAccesshttp://enable-cors.org ...

  9. Unable to save settings: Failed to save settings. Please restart IntelliJ IDEA

    找到原先备份的项目,把 .idea 文件夹重新覆盖,解决问题.

  10. Linux大牛分享的7道经典面试题和秒收 offer 的技巧

    笔者其实没有想到去面试,只是在智联上更新了一下简历,就陆陆续续接到很多猎头的邮件和电话,闲话少说,下面就分享给大家Linuxer的面试经历: 首先,猎头或者公司人资会把公司的介绍及岗位要求发到你邮箱( ...