1
2

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 5 years have passed since last update.

Python環境構築(pyenv + pipenv + anaconda)

Last updated at Posted at 2018-11-11

pyenvをinstall, globalでpythonを設定

pyenv

Linux

git clone https://github.com/pyenv/pyenv.git /usr/local/pyenv

/etc/profile.d/pyenv.shを以下の内容で作成

export PYENV_ROOT=“/usr/local/pyenv”
export PATH=“${PYENV_ROOT}/bin:${PATH}”
eval “$(pyenv init -)”

Mac

brew install pyenv
export PATH=“$HOME/.pyenv/shims:$PATH
pyenv install -l
pyenv install anaconda
pyenv global anaconda

pipenv

(sudo) pip install pipenv
https://pipenv-ja.readthedocs.io/ja/translate-ja/install.html
https://kashewnuts.github.io/2018/03/15/pipenv.html


pipenv install/shell をした場合に

ERROR: The executable /Users/{USER_NAME}/{USER_PROJECT_NAME}/.venv/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/{USER_NAME}/{USER_PROJECT_NAME}' (should be '/Users/{USER_NAME}/.local/share/virtualenvs')

とエラーになる場合がある。

※ デフォルトの挙動だと /Users/{USER_NAME}/.local/share/virtualenvs/プロジェクトのディレクトリ名+ハッシュ値 のように仮想環境名が決まるため

PIPENV_VENV_IN_PROJECT=true をbashrcなどに設定してsource.

これにより、プロジェクトディレクトリ(~/projects/hoge など)で pipenv install/shell した時に ~/projects/hoge/.venv となるように仮想環境を作成してくれます。


1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?