Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Python仮想環境構築の基礎と ツールの比較

最近のpython仮想環境について勉強したのでまとめました。勉強しながら作ったので間違っていることを書いてる可能性があります。

Typoが複数あったけどuploadしなおさない」

  • Be the first to comment

Python仮想環境構築の基礎と ツールの比較

  1. 1. Python 1
  2. 2. 5,6 pyenv virtualenv Python pyenv-virtualenv 2
  3. 3. 3
  4. 4. • SysML • pyenv-virtualenv • Python 4 @cocodrips
  5. 5. Python 3STEP
  6. 6. 1. Python 2. 3. 6 Python 3STEP
  7. 7. Python • ‣ : ProjectA: Python >= 3.6 ProjectB: Python >= 3.5 • pyenv 7
  8. 8. • ‣ : ProjectA: Tensorflow == 1.15.0 ProjectB: Tensorflow >= 2.1.0 • app docker 8
  9. 9. • ‣ pip requirements.txt ‣ pip freeze ‣ requirements/dev.txt — autopep8 / flake8 … requirements/tests.txt — pytest … requirements/prod.txt • 9
  10. 10. Python
  11. 11. pip • PyPI Python • pip freeze > requirements.txt 11 O
  12. 12. venv • Python3.3 python3 -m venv /path/to/environment • activate ( ) source /path/to/environment/bin/activate 12 O
  13. 13. 3rdParty
  14. 14. pyenv • ‣ — pyenv install 3.8.1 ‣ — pyenv local 3.8.1 • • (3.8.1) 14 O
  15. 15. pipenv • • requirements.txt Pipfile / Pipfile.lock ‣ npm / bundler ‣ requirements.txt • Pipfile Python (PEP) 15 O O
  16. 16. pipenv • ‣ pipenv —python <python path> • activate (shell ) ‣ pipenv shell 16 O O
  17. 17. pipenv • pipenv ‣ Pipfile pipenv install requirements ‣ pipenv install —dev autopep8 ‣ Pipfile.lock pipenv sync ‣ pipfile pipenv install 17 O O
  18. 18. poetry • Python project.toml • setup.py • npm / bundler poetry.lock • 18 O O
  19. 19. poetry 19 O O
  20. 20. poetry • poetry ‣ ( ) — pyproject.toml poetry new < > • activate ‣ poetry shell • ‣ pyenv local new, install ( pipenv ) 20 O O
  21. 21. poetry • poetry ‣ pyproject.toml poetry add requirements ‣ poetry add —dev autopep8 ‣ pyproject.tml poetry install ‣ poetry build 21 O O
  22. 22. ( ) Anaconda • STEP • • 22 O O O
  23. 23. ( ) pyenv-virtualenv • activate • pyenv virtualenv < > <env > • activate pyenv local <env > 23 O O
  24. 24. Python Before ——> After
  25. 25. (before) pyenv-virtualenv + pip • activate ( ) • (tf2), (tf1) • … 25
  26. 26. (after) pyenv + poetry • pyenv • ‣ python ‣ • pipenv • pip pipenv / poetry 26
  27. 27. 28 2020 Python - Qiita
  28. 28. • Pipfile → pipenv • requirements.txt → pip + venv • PyPI → poetry • → • — → pip+venv / pipenv 29

×