インストール
pyenv を使わない前提。
今まで使ってたけど、Cビルドを伴うライブラリインストールや、
エディタからのpython呼び出しでなんかハマることがあったので避けてみる。
- 公式パッケージで入れる。
- バージョンを切り替えて使う場合は必要なバージョンを全部入れて、
python3.5
みたいにバージョン指定して呼ぶ。
- virtualenv, venv を作るときにもpythonバージョンを指定する方法があった気がする。
virtualenv, venv
python3.6 -m venv venv
source venv/bin/activate
# 抜けるときは deactivate
追記
python.org が公式に推薦しているpipenvを使うのが今時とのこと。
開発前に入れておきたいライブラリ
basic_libraries.txt
ipython
ipdb
jupyter
flake8
hacking
flake8-docstrings
flake8-import-order
pytest
pytest-flake8
requests
pytz
- PyMySQL
orator peewee
- flask
も入れておいても良い気がした。
# venv に切り替えておいてから
pip install -r basic_libraries.txt
pytest.ini
[pytest]
norecursedirs = venv
python_files = test_*.py
addopts = -s -vv --flake8
flake8-ignore =
flake8-max-line-length = 119
~/.config/flake8
[flake8]
exclude =
.git,
__pycache__,
docs/source/conf.py,
old,
build,
dist
max-line-length = 119
Configuring Flake8 — flake8 3.5.0 documentation
.gitignore
githubのやつを使う。
追加で、
# custom
.idea
これ書くのに上記セットアップをしてた。
更に追記
バージョン依存な開発を行う場合もあるし、結局、
pyenv + pipenv
で行くことにした。