跳到主要內容

[Linux] 安裝 conda 並用 conda 安裝套件

本篇文章介紹 conda 在 Linux 安裝與基本使用方法。

conda 是一個套件包管理器,跟 apt-get 一樣。conda 的宗旨最初是為了管理複雜的 Python 語言包安裝,後來開始支援其它語言包的安裝(例如 R 語言)。

在 Linux 安裝 conda 指令無法採用 apt-get 指令,要安裝 conda 有兩種方式:

  1. 安裝 Anaconda。Anaconda 是一個 Python 的發行版,專門用於計算科學,內建很多的預設數據科學的軟體包,因此會安裝 Anaconda 會需要較大的硬碟空間,會安裝約 3 GB 大的檔案到電腦內。
  2. 安裝 Miniconda,是最小安裝版本的 Anaconda,內建 conda、Python 和一些基本套件和基本工具。我目前是安裝這個,因為我不想要安裝一些目前還用不到的語言包。
Minicoda 可以在這個網站下載。
我選擇 Python 2.7 的 Linux 64-bit 版本下載,安裝過程不需要使用 sudo 權限,否則之後 conda 執行上會有權限問題,conda 在執行的時候是無法使用 sudo conda ... 來執行指令的。

安裝過程如下(作業系統為 Linux 發行版:Elementary OS):

執行 (不需要加 sudo) 
bash ./Miniconda2-latest-Linux-x86_64.sh
會出現歡迎畫面:
Welcome to Miniconda2 4.7.12

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
按 Enter 後,閱讀完授權合約,輸入 yes 接受合約條款。

Do you accept the license terms? [yes|no]
[no] >>>
預設安裝路徑是家目錄的 minicoda2,按下 Enter 可即刻安裝。

Miniconda2 will now be installed into this location:
/home/edoczec/miniconda2

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/home/edoczec/miniconda2] >>>
等待安裝完成後,就會出現以下提示,需要我們重新開啟 Terminal Shell(即終端機)。
==> For changes to take effect, close and re-open your current shell. <==

If you'd prefer that conda's base environment not be activated on startup, 
   set the auto_activate_base parameter to false: 

conda config --set auto_activate_base false

Thank you for installing Miniconda2!
 接著嘗試用 conda 指令來安裝 LLVMlite 和 RPLY 這兩個語言包試試看:
先重開一個新的終端機,然後執行:

(指令一律不要加 sudo,否則會顯示找不到 conda 指令)
 conda install -c numba llvmlite
 conda install -c conda-forge rply
指令中的 -c 代表指定額外的套件倉庫別名。
安裝套件成功後,會顯示:
Preparing transaction: done
Verifying transaction: done
Executing transaction: done




留言

這個網誌中的熱門文章

[Linux] Elementary OS 字體調校

用 gesetting 取得 elementary os 的等寬字體(這也是終端機默認字體): gsettings get org.gnome.desktop.interface monospace-font-name 會顯示目前字型跟字體大小: Roboto Mono 10 設定字體大小: gsettings set org.gnome.desktop.interface monospace-font-name 'Roboto Mono 12' 可以微調 text-scaling-factor: gsettings set org.gnome.desktop.interface text-scaling-factor <value>

[Vim] 我的 .vimrc

我用過的文字編輯器有 sublime text/atom/notepad++/gedit 等等。 後來我在 window 和 Linux 寫程式還是比較慣用 vim。 以下整理我常用的 .vimrc:  set nu "show line number. set rnu "related line number. nmap ; : "replace ';' with ':' in normal mode. set ai "auto indent set mouse=a "activate mouse set expandtab "replace tab with space. set tabstop=4 "replace tab with 4 spaces. set bg=dark "background set to dark. color desert "color scheme. syntax on "enable syntax highlight. " auto complete: inoremap ( ()<Esc>i inoremap ' ''<Esc>i inoremap " ""<Esc>i inoremap [ []<Esc>i inoremap { {}<Esc>i set cursorline " active cursorline 到此 vim 搭配 Ctrl + N 當自動補全,已經很好用了,之後有好用設定會再補上來。

[C++] 計算程式執行時間:clock 和 time 函式

要計算一段程式碼執行時間,可以用 time 函式: 1 2 3 4 5 time_t start, end; start = time(NULL); // DO SOMETHING... end = time(NULL); cout " [Msg] total time: " difftime(end, start) " sec" endl; time 函式的精確度只到達秒,如果要精確到毫秒等級,要用 clock 函式: 1 2 3 4 5 6 clock_t start, end; start = clock(); // DO SOMETHING... end = clock(); cout ( double )(finish - start) / CLOCKS_PER_SEC endl;