ぴろの狂人日記

2014年から頑張ってブログを継続しようと思います。「継続と習慣」を今年の目標にしたので、頑張って更新を続けようと思います。おいおいはレビューや数学や認知科学などについて記事を書いていければと思っています

Macでpython3の環境構築1---Homebrewのインストール---

これから数回はMac上にpythonの環境構築をする過程を紹介しようと思います。

インストールするのはpython3です。

 

で、いろいろ調べてみると、pythonをインストールする下準備としてHomebrewというものをまずインストールしたほうがよいらしい。

 

Homebrewというものがいまいちなんなのかよくわかっていないし、pipやeasyinstallなんてものもあるようで、それらとの関係性もいまいち理解しきれていませんが、とりあえずインストールしてみます。

 

このあたりの説明が丁寧にされていう情報源があれば、どなたかご紹介願います。

 

まずはHomebrewのホームページへ行き、トップページに記載されているコマンドをコピーします。

 

 

 

それを、ターミナルのカーソルが点滅しているところにそのまま貼り付けをしreturnを押します。

 

そうすると、次のような処理が走ります。

 


Last login: Thu Aug 20 23:14:03 on ttys000

hiroshi-no-MacBook-Air:~ hiroshi$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"   #←これが貼り付けたコマンド、ここでreturnを押す

==> This script will install:

/usr/local/bin/brew

/usr/local/Library/...

/usr/local/share/man/man1/brew.1



Press RETURN to continue or any other key to abort


 

一番最後に


Press RETURN to continue or any other key to abort

 

と求められていますが、ここは指示通りreturnを押します。

すると続きが進み


WARNING: Improper use of the sudo command could lead to data loss

or the deletion of important system files. Please double-check your

typing when using sudo. Type "man sudo" for more information.



To proceed, enter your password, or type Ctrl-C to abort.



Password:   #PWを入力しても、入力されているようには見えないが、きちんとPCには認識されている。

 

パスワードを求められます。これはPCにログインするときのパスワードを入力します。入力しても文字が入力されていないように見えますが、きちんとPCには認識されています。気にせずキーを叩きreturnを押せば先へ進みます。

returnを押すと処理が進み次のようになります。


==> /usr/bin/sudo /bin/chmod g+rwx /usr/local

==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local

==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew

==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew

==> Downloading and installing Homebrew...

remote: Counting objects: 3707, done.

remote: Compressing objects: 100% (3542/3542), done.

remote: Total 3707 (delta 36), reused 511 (delta 26), pack-reused 0

Receiving objects: 100% (3707/3707), 3.06 MiB | 418.00 KiB/s, done.

Resolving deltas: 100% (36/36), done.

From https://github.com/Homebrew/homebrew

 * [new branch]      master     -> origin/master

HEAD is now at b63e755 update: only update renamed when necessary

==> Installation successful!

==> Next steps

Run `brew help` to get started

hiroshi-no-MacBook-Air:~ hiroshi$

 

一番下の行は、処理がひとまず終わり、次のコマンドの入力待ち、最初の状態。

で、次のようなことも念のためにやっておくと安心かも。確認作業ですが。

コマンドの入力待ちのところの続きで、カーソルが点滅しているところに、次のように入力します。


hiroshi-no-MacBook-Air:~ hiroshi$ brew doctor    #brew doctorを入力する。

 

そうすると、正しくインストールできていれば、


Your system is ready to brew.

 

と返されます。

最新 バージョンではない可能性もあるので、次のようなコマンドも打っておきます。


hiroshi-no-MacBook-Air:~ hiroshi$ brew update

 

そうすると、今回は最新バージョンだったようなので、


Already up-to-date.

 

と返ってきます。

 

 

 

このあとにpythonのインストールをするわけですが、それは次回にします。

ここまでの画面の流れを最後にまとめておきます。


hiroshi-no-MacBook-Air:~ hiroshi$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

==> This script will install:

/usr/local/bin/brew

/usr/local/Library/...

/usr/local/share/man/man1/brew.1



Press RETURN to continue or any other key to abort

==> /usr/bin/sudo /bin/mkdir /usr/local



WARNING: Improper use of the sudo command could lead to data loss

or the deletion of important system files. Please double-check your

typing when using sudo. Type "man sudo" for more information.



To proceed, enter your password, or type Ctrl-C to abort.



Password:(コメント→PWを入力しても、入力されているようには見えないが入力されている)

==> /usr/bin/sudo /bin/chmod g+rwx /usr/local

==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local

==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew

==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew

==> Downloading and installing Homebrew...

remote: Counting objects: 3707, done.

remote: Compressing objects: 100% (3542/3542), done.

remote: Total 3707 (delta 36), reused 511 (delta 26), pack-reused 0

Receiving objects: 100% (3707/3707), 3.06 MiB | 418.00 KiB/s, done.

Resolving deltas: 100% (36/36), done.

From https://github.com/Homebrew/homebrew

 * [new branch]      master     -> origin/master

HEAD is now at b63e755 update: only update renamed when necessary

==> Installation successful!

==> Next steps

Run `brew help` to get started

hiroshi-no-MacBook-Air:~ hiroshi$ brew doctor

Your system is ready to brew.

hiroshi-no-MacBook-Air:~ hiroshi$ brew update

Already up-to-date.

 

 

参考にしたページ

作業環境を整えるMacOSXのパッケージマネージャ「Homebrew」のインストール方法と使い方 | 株式会社LIG

 

Homebrew — OS X用パッケージマネージャー

 

Homebrewを使ってMacにPython3とかNumpyとかScipyとかをインストールする - 開発のヒホ

 

MacにHomebrewを導入する方法&使い方まとめ

 

Macのツールを楽にインストールできるパッケージ管理システムHomebrewの使い方

 

macにpython3系のインストールメモ

 

MacでPythonの機械学習環境構築(2015年2月版) - old school magic

 

MacOSX - パッケージ管理システム Homebrew - Qiita

 

Ruby - Homebrewをインストールしたときに出るWarningの対処 - Qiita