ä»åã¯Pythonã§æ©æ¢°å¦ç¿ãè¡ãããã«å¿ è¦ãªç°å¢æ§ç¯ã®ä¸é£ã®æµããè¨äºã«ãã¾ãããPythonã®ãã¼ã¸ã§ã³ç®¡çãè¡ãpyenvã³ãã³ããæ´»ç¨ããæ©æ¢°å¦ç¿ãè¡ãããã±ã¼ã¸ãAnacondaãã®ã¤ã³ã¹ãã¼ã«ã¨åæå¯è¦åç°å¢ãJupyter Notebookããæ§ç¯ãã¦ã¿ã¾ãã
- æ¬è¨äºã®ç®ç
- pyenvã¨ã¯
- pyenvã®ã¤ã³ã¹ãã¼ã«
- Anacondaã¨ã¯
- pyenvã§Anacondaãã¤ã³ã¹ãã¼ã«
- Jupyter Notebookã¨ã¯
- Jupyter Notebookã®æ´»ç¨
æ¬è¨äºã®ç®ç
æ¬è¨äºã¯ä»¥ä¸ãç®çã¨ãã¦ãã¾ãã
ã»pyenvã³ãã³ããJupyterã®ç解
ã»Pythonã®åæç°å¢ã®æ§ç¯æ¹æ³ã®ç解
pyenvã¨ã¯
pyenvã¯Pythonã®ãã¼ã¸ã§ã³ãåãæ¿ãããã¼ã«ã§ããMacãªã©æ¢ã«Pythonãã¤ã³ã¹ãã¼ã«ããã¦ããã¾ãããã¤ã³ã¹ãã¼ã«ããã¦ãããã¼ã¸ã§ã³ã¯Python2ç³»ã§ãã
Pythonã®ãã¼ã¸ã§ã³ã¯2ç³»ã¨3ç³»ãããã2ç³»ã®ãµãã¼ãã¯2020å¹´ã§çµäºãããã3ç³»ã«å¯¾å¿ãããã¨ãæã¾ããã§ãã
ã¾ããä»åã¯æ©æ¢°å¦ç¿ã«å¿
è¦ãªã©ã¤ãã©ãªãå
å
ããããã±ã¼ã¸Anacondaã®Python3ç³»ã使ãããã®ã§ãPython2ç³»ããAnacondaã®Python3ç³»ã«ãã¼ã¸ã§ã³ãåãæ¿ããéå½¹ç«ã¡ã¾ãã
pyenvã®ã¤ã³ã¹ãã¼ã«
å®éã«pyenvãã¤ã³ã³ã¹ãã¼ã«ãããã¨æãã¾ãã
ã¾ããGITã§pyenvãã¯ãã¼ã³ããpyenvã³ãã³ããæ±ããããã«OSãåç
§ããè¨å®ãã¡ã¤ã«[.bash_profile]ãæ´æ°ãã¾ãã
# ç¾å¨ã®ãã¼ã¸ã§ã³ $ python --version # Out Python 2.7.9 # ã¯ãã¼ã³ $ git clone git://github.com/yyuu/pyenv.git ~/.pyenv # Out Cloning into '/home/keisukegcp1234/.pyenv'... remote: Counting objects: 16462, done. remote: Compressing objects: 100% (19/19), done. remote: Total 16462 (delta 11), reused 26 (delta 11), pack-reused 16429 Receiving objects: 100% (16462/16462), 3.20 MiB | 0 bytes/s, done. Resolving deltas: 100% (11168/11168), done.
pyenvã®DLã¯å®äºããã®ã§ã以ä¸ã®ã³ãã³ããå®è¡ããbash_profileã®ç·¨éããã¾ãã
bash_profileã¯ãã°ã¤ã³ããéã«èªã¿è¾¼ã¾ããè¨å®ãã¡ã¤ã«ã§ãã
https://wa3.i-3-i.info/word13650.html
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile $ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile $ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
.bash_profileãæ´æ°ã§ããã®ã§ãè¨å®ãã¡ã¤ã«ãèªã¿è¾¼ã¿ã¾ãã
.bash_profileã¯Linuxã«ãã°ã¤ã³ããéã«èªã¿è¾¼ã¾ããã®ã§ã以ä¸ã®ã³ãã³ããå®è¡ããªãã¨ç·¨éããè¨å®ãã¡ã¤ã«ã®å
容ãé©ç¨ããã¾ããã
source ~/.bash_profile
Anacondaã¨ã¯
Anacondaã¨ã¯Pythonã§æ©æ¢°å¦ç¿ãè¡ãããã«å¿
è¦ãªã©ã¤ãã©ãªãå
å
ããããã±ã¼ã¸ã§ãã
é常ã¯å¿
è¦ãªã©ã¤ãã©ãªã1ã¤ãã¤æ§ç¯ããç°å¢ã«PIPã³ãã³ããªã©ã§ã¤ã³ã¹ãã¼ã«ãã¦ããå¿
è¦ãããã¾ãããAnacondaãã¤ã³ã¹ãã¼ã«ããã°ãã®æéãçããã¨ãå¯è½ã§ããä¸è¦ãªã©ã¤ãã©ãªãå«ãã§ãããããä½åã«ãã£ã¹ã¯å®¹éã¯ã¨ãã¾ãããå
¥éã¨ãã¦æ©æ¢°å¦ç¿ã®åæç°å¢ãæ§ç¯ããã«ã¯Anacondaãæ¨å¥¨ãã¾ãã
pyenvã§Anacondaãã¤ã³ã¹ãã¼ã«
ã¤ã³ã¹ãã¼ã«ããpyenvã³ãã³ãã§Anacondaãã¤ã³ã¹ãã¼ã«ãã¾ãã
ã¾ããpyenvã§ã¤ã³ã¹ãã¼ã«å¯è½ãªããã±ã¼ã¸ã確èªããAnacondaã®ææ°çãã¤ã³ã¹ãã¼ã«ãã¾ãã
Anacondaã®ã¤ã³ã¹ãã¼ã«ãå®äºããããpenvã³ãã³ãã§Pythonã®ãã¼ã¸ã§ã³åãæ¿ããè¡ãã¾ãã
# pyenv ã¤ã³ã¹ãã¼ã«å¯è½ããã±ã¼ã¸ $ pyenv install --list # Out ãã»ã»ã»ã» anaconda3-5.1.0 anaconda3-5.2.0 # anacondaã®ã¤ã³ã¹ãã¼ã« $ pyenv install anaconda3-5.2.0 # Out Downloading Miniconda3-4.3.30-Linux-x86_64.sh... -> https://repo.continuum.io/miniconda/Miniconda3-4.3.30-Linux-x86_64.sh Installing Miniconda3-4.3.30-Linux-x86_64... Fetching package metadata ........... Solving package specifications: . # Pythonåãæ¿ã $ pyenv global anaconda3-5.2.0 # ç¢ºèª $ python --version Python 3.6.3 :: Anaconda, Inc.
Jupyter Notebookã¨ã¯
Jupyter Notebookã¨ã¯å¤§è¦æ¨¡ãã¼ã¿ã®åæã«å½¹ç«ã¤Pythonã®å¯è¦åãã¼ã«ã§ãã
ãã©ã¦ã¶ããã¤ã³ã¿ã©ã¯ãã£ãã«Pythonããã°ã©ã ã®å®è¡ã¨å®è¡çµæã確èªãããã¨ãã§ãã¾ãã
æ©æ¢°å¦ç¿ãå°ããªãã¼ã¿ã§ããã°ãExcelã§ãæ§ãã¾ãããã大è¦æ¨¡ãã¼ã¿ã®å å·¥ãã°ã©ãã®å¯è¦åã
æ©æ¢°å¦ç¿ã®å®è¡çµæã確èªããã«ã¯Jupyterã§ãªãã¨é£ããã§ãã
Jupyter Notebookã®æ´»ç¨
Anacondaãã¤ã³ã¹ãã¼ã«ããã¨ãå
å
ããã©ã¤ãã©ãªã«Jupyterãå«ã¾ãã¦ãã¾ãã
以ä¸ã®ã³ãã³ããå®è¡ãJupyter Notebookããã©ã¦ã¶ãã確èªãã¦ã¿ã¾ããã
$ jupyter notebook --port 8080 # Out Copy/paste this URL into your browser when you connect for the first time, to login with a token: http://localhost:8080/?token=a2df88b54bceb92d3286bcc95f60eda4e181954f4c98ea41
ãã©ã¦ã¶ããJupyter Notebookã確èªãããã¨ãã§ãã¾ããã
以ä¸ã§ãç°å¢æ§ç¯å
¥éãå®äºã¨ãã¾ãã
åèè¨äº
pyenvを使ってMacにPythonの環境を構築する - Qiita
Pythonを書き始める前に見るべきTips - Qiita
Pyenvの使い方 - Qiita
pyenvのインストール、使い方、pythonのバージョン切り替えできない時の対処法 - Qiita
データサイエンティストを目指す人のpython環境構築 2016 - Qiita