关于linux:miniconda集成环境的安装使用

5次阅读

共计 3308 个字符,预计需要花费 9 分钟才能阅读完成。

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


  1. 在 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 ~]# ls
Miniconda-3.16.0-Linux-x86_64.sh
  1. 执行脚本,进行装置, 在装置过程中,会要你进行几次抉择
[root@localhost ~]# /bin/bash Miniconda-3.16.0-Linux-x86_64.sh
Do you approve the license terms? [yes|no]
[no] >>> yes
Miniconda 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] >>> /miniconda
Do you wish the installer to prepend the Miniconda install location
to PATH in your /root/.bashrc ? [yes|no]
[no] >>> no
You may wish to edit your .bashrc or prepend the Miniconda install location:
$ export PATH=/miniconda/bin:$PATH
Thank you for installing Miniconda!
[root@localhost ~]#
  1. 编辑 ~/.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 functions
if [-f ~/.bashrc]; then
 . ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export PATH=/miniconda/bin:$PATH
[root@localhost ~]# source ~/.bash_profile
  1. 测试 conda -V 查看 conda 版本
[root@localhost ~]# conda -V
conda 3.16.0

至此miniconda 装置胜利!

3.windows 装置 miniconda


  1. https://conda.io/miniconda.html 进入官网下载 Miniconda 安装包
  2. 而后装置一路 Next;

4. Conda 的应用


  1. 配置 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
  1. 创立虚拟环境
[root@localhost ~]# conda create -n py36 python=3.6
Fetching package metadata: ........
# 中途下载会须要一点点工夫,请急躁期待 
100%
# To activate this environment, use:
# $ source activate py36
#
# To deactivate this environment, use:
# $ source deactivate
[root@localhost ~]#
  1. 进入虚拟环境,并查看有哪些曾经装置好的包
[root@localhost ~]# source activate py36
(py36)[root@localhost ~]# conda list
# packages in environment at /miniconda/envs/py36:
# 省略...
python                    3.6.2                         0    defaults
readline                  6.2                           2    <unknown>
setuptools                41.0.1                   py36_0 
# 省略...
  1. 尝试装置其余第三方的包,这里咱们以 requestspyspark为例
(py36)[root@localhost ~]# pip install requests
Successfully 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 pyspark
Looking in indexes: http://pypi.douban.com/simple
Collecting pyspark
 Downloading http://pypi.doubanio.com/.../pyspark-2.4.3.tar.gz (215.6MB)
 |████████████████████████████████| 215.6MB 2.0MB/s
 # 如果发现下载速度慢,能够 Ctrl+ C 勾销重试,这里我第二次才达到 2.0MB/s
Successfully installed pyspark-2.4.3
(py36)[root@localhost ~]# pip list
# 省略...
pyspark    2.4.3
requests   2.22.0
# 省略...

小结:那么这个就是我的装置过程了,然而给到大家一个倡议。初学者不要应用这个集成环境,学习过程中,咱们还是一步步来体验学习的每一个过程比拟好。
你学废了吗?

正文完
 0