3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

M1 MacbookAirでpython環境を整える(備忘録)

Last updated at Posted at 2021-03-21

2021/3/21時点で
M1チップにpipなど対応していない多い模様。pandasなどもインストールできないので
とりあえず、M1チップのMacでPythonが動く環境を整える。

xcodeをインストール

ターミナルで下記のコマンドでxcodeをインストール

xcode-select --install

下記のようなメッセージが出た場合は、インストールを選択し、そのまま進めていきます。

Miniforge3をインストール

Miniforge3をダウンロードしていきます。 https://github.com/conda-forge/miniforge

まず、ここ からarm64 (Apple Silicon)用のスクリプトをダウンロードしてホームディレクトリに置きます。
その後、ターミナルで下記のコマンドを実行します。
 

bash Miniforge3-MacOSX-arm64.sh

~/.zshrcに色々書き込まれているようなので、下記コマンドで反映

source ~/.zshrc

仮想環境を設定

conda create -n myenv python=3.9
conda activate myenv

あとはconda install・・・でinstallができる。

conda install -c anaconda pandas
conda install -c anaconda scipy
conda install -c conda-forge matplotlib
conda install -c anaconda networkx

mysqlのインストール

まず、Homebrewをインストールします。
https://brew.sh/index_ja
からコマンドをコピーしてきて、ターミナルに貼り付け実行
brewのインストールが終わると、下記のような指示が出ているの赤枠でくくったところをターミナルで1行ずつ実行。(パスを通す作業)
addpath.png
ターミナルで

brew help

を実行してhelpが表示されたらOK

brew install mysql

でmysqlをインストール

mysql.server start

でMySQLを起動

mysql -uroot

でrootユーザーログインできる。

pythonでmysqlを使うために

pip install mysql-connector-python

condaではインストールできず。。。

文字化け防止

https://ja.osdn.net/projects/ipafonts/releases/57327
ここからzipファイルをダウンロードして解凍したipaexg00201フォルダを
ライブラリフォルダ内のFontsにコピー
キャッシュが残っているかもしれないので、下記コマンドでキャッシュを削除

rm -rf ~/.matplotlib/

opencvのインストール

conda install opencv

face-recognitionはcondaでインストールできなかったので、pipでインストールした。。。cmakeをインストールしないとface-recognitionはインストールできない

brew install cmake
pip install face-recognition

mysql-connector-pythonもcondaでインストールできなかったので、pipでインストール

pip install mysql-connector-python
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?