1. Conda是什么
Conda是一个开源的包、环境管理器,能够用于在同一个机器上装置不同版本的软件包及其依赖,并可能在不同的环境之间切换。
Anaconda包含Conda、Python以及一大堆装置好的工具包,比方:numpy、pandas等。
Anaconda 安装包能够到 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 下载。
Miniconda 是一个 Anaconda 的轻量级代替,默认只蕴含了 python 和 conda,然而能够通过 pip 和 conda 来装置所须要的包。
Miniconda 安装包能够到 https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/ 下载。
2. cones装置Miniconda
- 在linxu中通过该链接下载失去脚本
[root@localhost ~]# wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda-3.16.0-Linux-x86_64.sh已保留 “Miniconda-3.16.0-Linux-x86_64.sh” [24166764/24166764])[root@localhost ~]# lsMiniconda-3.16.0-Linux-x86_64.sh
- 执行脚本,进行装置, 在装置过程中,会要你进行几次抉择
[root@localhost ~]# /bin/bash Miniconda-3.16.0-Linux-x86_64.shDo you approve the license terms? [yes|no][no] >>> yesMiniconda will now be installed into this location:/root/miniconda - Press ENTER to confirm the location - Press CTRL-C to abort the installation - Or specify a different location below[/root/miniconda] >>> /minicondaDo you wish the installer to prepend the Miniconda install locationto PATH in your /root/.bashrc ? [yes|no][no] >>> noYou may wish to edit your .bashrc or prepend the Miniconda install location:$ export PATH=/miniconda/bin:$PATHThank you for installing Miniconda![root@localhost ~]#
- 编辑
~/.bash_profile
, 参照第3步执行命令后的提醒,把export PATH=/miniconda/bin:$PATH
增加到~/.bash_profile
文件开端,最初执行source ~/.bash_profile
让其失效
[root@localhost ~]# vim ~/.bash_profile您在 /var/spool/mail/root 中有邮件[root@localhost ~]# cat ~/.bash_profile# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then . ~/.bashrcfi# User specific environment and startup programsPATH=$PATH:$HOME/binexport PATHexport PATH=/miniconda/bin:$PATH[root@localhost ~]# source ~/.bash_profile
- 测试
conda -V
查看conda版本
[root@localhost ~]# conda -Vconda 3.16.0
至此miniconda装置胜利!
3.windows装置miniconda
- https://conda.io/miniconda.html进入官网下载Miniconda安装包
- 而后装置一路Next;
4. Conda的应用
- 配置anaconda仓库镜像源
[root@localhost ~]# conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/[root@localhost ~]# conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/[root@localhost ~]# conda config --set show_channel_urls yes
- 创立虚拟环境
[root@localhost ~]# conda create -n py36 python=3.6Fetching package metadata: ........# 中途下载会须要一点点工夫,请急躁期待 100%# To activate this environment, use:# $ source activate py36## To deactivate this environment, use:# $ source deactivate[root@localhost ~]#
- 进入虚拟环境,并查看有哪些曾经装置好的包
[root@localhost ~]# source activate py36(py36)[root@localhost ~]# conda list# packages in environment at /miniconda/envs/py36:# 省略...python 3.6.2 0 defaultsreadline 6.2 2 <unknown>setuptools 41.0.1 py36_0 # 省略...
- 尝试装置其余第三方的包,这里咱们以
requests
和pyspark
为例
(py36)[root@localhost ~]# pip install requestsSuccessfully installed chardet-3.0.4 idna-2.8 requests-2.22.0 urllib3-1.25.3# 这个第三方包比拟小,还能容易的装置,但如果碰到比拟大的第三方包就难堪了,因而这里咱们增加一个国内的pypi镜像地址(py36)[root@localhost ~]# mkdir -p ~/.pip/(py36)[root@localhost ~]# vim ~/.pip/pip.conf(py36)[root@localhost ~]# cat ~/.pip/pip.conf # pip.conf内容如下[global]index-url = http://pypi.douban.com/simple[install]trusted-host=pypi.douban.com(py36)[root@localhost ~]# pip install pysparkLooking in indexes: http://pypi.douban.com/simpleCollecting pyspark Downloading http://pypi.doubanio.com/.../pyspark-2.4.3.tar.gz (215.6MB) |████████████████████████████████| 215.6MB 2.0MB/s # 如果发现下载速度慢,能够Ctrl+C勾销重试,这里我第二次才达到2.0MB/sSuccessfully installed pyspark-2.4.3(py36)[root@localhost ~]# pip list# 省略...pyspark 2.4.3requests 2.22.0# 省略...
小结:那么这个就是我的装置过程了,然而给到大家一个倡议。初学者不要应用这个集成环境,学习过程中,咱们还是一步步来体验学习的每一个过程比拟好。
你学废了吗?