miniconda集成環境的安裝使用

1. Conda是什麼


Conda是一個開源的包、環境管理器,能夠用於在同一個機器上安裝不一樣版本的軟件包及其依賴,並可以在不一樣的環境之間切換。html

Anaconda包括Conda、Python以及一大堆安裝好的工具包,好比:numpy、pandas等。python

Anaconda 安裝包能夠到 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 下載。vim

Miniconda 是一個 Anaconda 的輕量級替代,默認只包含了 python 和 conda,可是能夠經過 pip 和 conda 來安裝所須要的包。segmentfault

Miniconda 安裝包能夠到 https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/ 下載。windows

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安裝成功!bash

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
# 省略...

小結:那麼這個就是個人安裝過程了,可是給到你們一個建議。初學者不要使用這個集成環境,學習過程當中,咱們仍是一步步來體驗學習的每個過程比較好。
你學廢了嗎?
imageapp

相關文章
相關標籤/搜索