ぺーぱーふぇいす

雑記と備忘録。私はプログラマ。

【Ubuntu Server 18.04】Anacondaをインストールする

Ubuntu Server 18.04にPythonの実行環境、および開発環境として手っ取り早くAnacondaをインストールする。

Anacondaのインストールスクリプトを取得

Ubuntu Serverではなく、GUIが動く別マシンのwebブラウザで下記にアクセスする。

https://www.anaconda.com/distribution/

サイト中のDownloadボタンに設定されているURLを取得する。
例としてChromeの場合は[リンクアドレスのコピー]をクリックして取得する。

これを書いている時点では、https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.shでした。

wgetでインストールスクリプトをダウンロード

クライアントでそのままダウンロードしたのをサーバに転送しても良いけど、二度手間な気がするので直接サーバ側でダウンロードさせる。
ダウンロードにはwgetを使う。

$ wget https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh   

インストール

起動とライセンスへの同意

インストーラシェルスクリプトなので、下記コマンドでbashに渡します。

$ bash Anaconda3-2019.03-Linux-x86_64.sh

起動するとライセンスを表示する旨が表示されるので、Enter。

Welcome to Anaconda3 2019.03

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>

Anacondaのライセンスが表示される。
スペースキーでスクロールして読んでいく。

===================================
Anaconda End User License Agreement
===================================

Copyright 2015, Anaconda, Inc.

All rights reserved under the 3-clause BSD License:

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the followi
ng conditions are met:

<中略>

最後までスクロールすると、ライセンスに同意するかどうか問われる。
同意できる場合のみyesと入力してEnter。

Do you accept the license terms? [yes|no]
[no] >>> yes

インストール場所の設定

インストール場所を問われる。デフォルトで構わないのでEnter。
そうでなければパスを入力してEnter。

Anaconda3 will now be installed into this location:
/home/<user_name>/anaconda3

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

[/home/<user_name>/anaconda3] >>>

インストールが始まる。しばらく時間がかかる。

condaの初期化

condaの初期化を行うのであればyesと入力してEnter。

installation finished.
Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]
[no] >>> yes

インストール確認

一度ログアウトするなり、bashを起動するなりしてPATHを読み込み直す。
conda -Vでcondaのバージョンが表示されるか確認。

$ conda -V
conda 4.6.11

また、Pythonインタラクティブシェルを起動してみて、表示がAnacondaとなっていることやnumpyなどのパッケージをimportしてもエラーとならにことを確認。

$ python
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> 

おわり

これで終わり🌱

condaの使い方とかは下記を参照。

qiita.com