Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Python 環境構築方法 2016

2bo
October 16, 2016

Python 環境構築方法 2016

機械学習名古屋 第7回勉強会 発表資料

2bo

October 16, 2016
Tweet

More Decks by 2bo

Other Decks in Programming

Transcript

  1. ͓લ୭Α • ໊લɿ
 ௶಺ ༝޹ (@2box2bo) • blogɿ
 http://www.zumwalt.info/blog •

    ॴଐ
 EjectίϚϯυϢʔβʔձ
 http://eject.kokuda.org/
 Python౦ւ (ڞಉ؅ཧਓ)
 http://connpass.com/series/292/
  2. Agenda • PythonԾ૝؀ڥ • Linux(CentOS) ΁ͷΠϯετʔϧखॱ • macOS ΁ͷΠϯετʔϧखॱ •

    pyenv-virtualenvͷ࢖͍ํ • Windows10 ΁ͷΠϯετʔϧखॱ • Anacondaͷ࢖͍ํ
  3. ؆୯ͳ·ͱΊ • pyenv • ෳ਺όʔδϣϯͷPythonΛ੾Γସ͑ͯ࢖͑Δɻ • WindowsͰ͸࢖͑ͳ͍ɻ • virtualenv •

    PythonͷϥΠϒϥϦ؀ڥΛ੾Γସ͑ͯ࢖͑Δɻ • WindowsͰ࢖͑Δɻ • pyenv-virtualenv • pyenvʹvirtualenvͷػೳΛ௥Ճ͢Δɻ • WindowsͰ͸࢖͑ͳ͍ɻ
  4. pyenv Πϯετʔϧ • ඞཁύοέʔδͷΠϯετʔϧ # yum install -y gcc gcc-c++

    make git patch openssl-devel zlib-devel readline-devel sqlite- devel bzip2-devel • μ΢ϯϩʔυ # git clone https://github.com/yyuu/pyenv.git / usr/local/pyenv/
  5. pyenv-virtualenv Πϯετʔϧ • pyenv-virtualenv Πϯετʔϧ # cd /usr/local/pyenv/plugins/ # git

    clone https://github.com/yyuu/pyenv-virtualenv.git # git clone https://github.com/yyuu/pyenv-virtualenvwrapper.git
  6. pyenv-virtualenv Πϯετʔϧ • ؀ڥม਺ઃఆ # cat <<EOF >> ~/.bashrc if

    [ -f /usr/local/pyenv/bin/pyenv ]; then export PYENV_ROOT="/usr/local/pyenv" export PATH="/usr/local/pyenv/bin:\$PATH" eval "\$(pyenv init -)" PS1='(pyenv:\`pyenv version-name\`)'\$PS1 fi EOF
  7. HomeBrew Πϯετʔϧ • ඞཁύοέʔδͷΠϯετʔϧ $ ruby -e "$ curl -fsSL

    https:// raw.githubusercontent.com/Homebrew/install/ master/install ” • ҎԼ͕දࣔ͞ΕͨΒEnter Press RETURN to continue or any other key to abort
  8. pyenv-virtualenv Πϯετʔϧ • pyenv-virtualenv Πϯετʔϧ $ brew install pyenv-virtualenv •

    ؀ڥม਺ઃఆ $ echo 'export PYENV_ROOT="/usr/local/var/pyenv"' >> ~/.bash_profile $ echo 'if which pyenv > /dev/null then eval "$ pyenv init - " fi' >> ~/.bash_profile $ echo 'if which pyenv-virtualenv-init > /dev/null then eval "$ pyenv virtualenv-init - " fi' >> ~/.bash_profile $ source .bash_profile
  9. pyenv-virtualenvͷ࢖͍ํ • python Ծ૝؀ڥ࡞੒ # pyenv virtualenv [Pythonόʔδϣϯ] [Ծ૝؀ڥ໊] ྫ)

    # pyenv virtualenv 2.7.11 Py2Base
 # pyenv virtualenv Py2Base py2-test Ծ૝؀ڥ͔Β৽͍͠Ծ૝؀ڥΛ࡞ͬͨ৔߹͸ϥ ΠϒϥϦ౳΋Ҿ͖ܧ͕Ε·͢
  10. pyenv-virtualenvͷ࢖͍ํ • ඪ४Ͱ࢖༻͢ΔPythonΛมߋ # pyenv global [Ծ૝؀ڥ໊] • ݱࡏͷshellͷPythonΛมߋ #

    pyenv shell [Ծ૝؀ڥ໊] • ݱࡏͷσΟϨΫτϦͷPythonΛมߋ # pyenv local [Ծ૝؀ڥ໊]
  11. pyenv-virtualenvͷ࢖͍ํ • Ծ૝؀ڥͷҰཡදࣔ # pyenv versions • PyEnvͷΞοϓσʔτ # cd

    /usr/local/pyenv # git pull 
 ৽͍͠VersionͷPythonΛΠϯετʔϧ͢Δ࣌ʹ ΞοϓσʔτΛ࣮ࢪ͢Δ
  12. Anacondaͷ࢖͍ํ • ΠϯετʔϧՄೳͳPythonͷදࣔ > conda search • Ծ૝؀ڥߏங > conda

    create -n [໊લ] python=[Versionࢦఆ] • Ծ૝؀ڥҰཡදࣔ > conda env list
  13. Anacondaͷ࢖͍ํ • Ծ૝؀ڥ࡟আ > conda remove -n [໊લ] —all •

    Ծ૝؀ڥ੾Γସ͑ > activate [໊લ] • Ծ૝؀ڥΛൈ͚Δ > deavtivate