about
win10 + anaconda
下载
- 官网,下载个人版:https://www.anaconda.com/products/individual#Downloads
- 但官网下载比较慢,推荐使用清华源下载:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
有了anaconda,还有安装Python么?
anaconda是集成了Python和预装了科学计算的库和其他的第三方库,且记成了包管理工具conda。
一般的有了anaconda,就不用再装Python了,同时也支持多种发行版本共存。
anaconda有anaconda2和anaconda3分别对应Python2和Python3。
安装
安装过程
- 以管理员权限运行exe文件,然后next
- I agree
- 为所有用户安装
- 安装位置不允许有中文、空格等特殊字符,且记住安装位置
- 高级配置,按图操作
- 短暂的安装过程,完事提示安装成功
在开始栏就安装了这些:
注意,安装位置是这里:C:\ProgramData\Anaconda3,注意,如果你在C盘根目录没有发现ProgramData目录的话,说明这个目录被隐藏了,你点击"查看",勾选"隐藏项目"就显示出来了。
配置系统变量
注意是系统变量,而不是用户变量。我这里anaconda安装在C:\ProgramData中
| 系统变量 | 路径 | 说明 |
|---|---|---|
| Path | C:\ProgramData\Anaconda3 | Python需要 |
| Path | C:\ProgramData\Anaconda3\Scripts | conda自带脚本 |
| Path | C:\ProgramData\Anaconda3\Library\bin | jupyter notebook动态库 |
| Path | C:\ProgramData\Anaconda3\Library\mingw-w64\bin | 使用C with python的时候 |
| Path | C:\ProgramData\Anaconda3\Library\usr\bin | 没有该目录就算了 |
由于版本不一致,可能有些目录不存在,没有就算了。
测试是否安装成功
终端中输入如下几个命令,正常返回说明安装成功,否则检查添加path是否成功,或者重启系统后尝试:
python -V
conda info
conda --version
配置国内镜像源
一些第三方的包的官网都在国外,导致下载太慢或者无法下载。这里提供配置国内的镜像源:
# 添加清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes
查看是否修改好通道?
conda config --show channels
虚拟环境管理
# 查看conda的配置
conda config --show
# 修改配置
conda config --add key value
conda config --remove key value
# 检查更新当前的conda管理工具
conda update -n base -c defaults conda -y
# 查看当前环境已安装的包
conda list
pip list
pip freeze
# 创建虚拟环境,指定虚拟环境的Python版本,不指定的话,默认跟anaconda的默认Python解释器版本
# 注意,使用conda config --show查看envs_dirs指向的路径,该路径是虚拟环境的默认安装位置,你也可以修改这个值
conda create -n 虚拟环境名称 python=3.6 -y
# 修改虚拟环境的保存位置,默认是保存到了用户家目录下
conda config --add envs_dirs C:\ProgramData\Anaconda3\envs
# 激活/退出虚拟环境
conda activate 虚拟环境名称
conda deactivate
# 为指定虚拟环境安装指定包,删除指定包;当然,也可以在激活虚拟环境后,使用pip下载
conda install -n 虚拟环境名称 包名 -y
conda remove -n 虚拟环境名称 包名 -y
# 查看所有虚拟环境
conda info --envs
conda info -e
conda env list
# 删除指定虚拟环境
conda remove -n 虚拟环境名称 --all -y
使用
# 搜索可用的包
anaconda search -t conda requests
# 如果你不知道使用命令进行安装,执行下面命令来获取安装命令
anaconda show requests
这里举个例子,我有个虚拟环境py39中使用正常的方式无法下载dbutils模块,显示这样的结果:
C:\Users\Anthony>conda install dbutils -n py39 -y
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- dbutils
Current channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
- https://repo.anaconda.com/pkgs/main/win-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/win-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/msys2/win-64
- https://repo.anaconda.com/pkgs/msys2/noarch
To search for alternate channels that may provide the conda package you\'re
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
这下只能搜索其他可用的包了:
C:\Users\Anthony>anaconda search -t conda dbutils # 搜索可用的包
Using Anaconda API: https://api.anaconda.org
Packages:
Name | Version | Package Types | Platforms | Builds
------------------------- | ------ | --------------- | --------------- | ----------
CEFCA/dbutils | 1.1 | conda | linux-64, linux-32, osx-64 | py27_0
: Database connections for multi-threaded environments.
auto/dbutils | 1.1 | conda | linux-64, linux-32 | py27_0
: http://www.webwareforpython.org/DBUtils
conda-forge/gmpyinfr_dbutils | 0.0.7 | conda | noarch | pyhd8ed1ab_0
: Infraestrutura dbutils python de uma equipe de Ciência de Dados
mcrot/dbutils | 1.1 | conda | win-32 | py27_0
: Database connections for multi-threaded environments.
qian_bi/dbutils | 1.3 | conda | noarch | py_0
: Database connections for multi-threaded environments.
Found 5 packages
Run \'anaconda show <USER/PACKAGE>\' to get installation details
C:\Users\Anthony>anaconda show qian_bi/dbutils # 这一步就是一个个试,找下载方式
Using Anaconda API: https://api.anaconda.org
Name: dbutils
Summary: Database connections for multi-threaded environments.
Access: public
Package Types: conda
Versions:
+ 1.3
To install this package with conda run:
conda install --channel https://conda.anaconda.org/qian_bi dbutils
开始下载吧:
C:\Users\Anthony>conda install --channel https://conda.anaconda.org/qian_bi dbutils -n py39 -y
.........
done
that\'s all,see also:
【Anaconda教程01】怎么安装Anaconda3 | Anaconda3详细安装使用教程及问题总结 | Anaconda多版本Python管理以及TensorFlow版本的选择安装 | jupyter notebook win10设置启动路径,并配置远程访问,开机自启动不弹窗 | Python 技术篇-设置windows开机自动启用Jupyter服务,BAT批处理脚本启用jupyter服务设置,设置jupyter默认启动位置的方法 | conda虚拟环境 | anaconda安装不存在的包