利用者:Brita/Configs/Pyenv

提供: wiki
< 利用者:Brita‎ | Configs
2018年4月22日 (日) 02:51時点におけるwiki>Britaによる版
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

pyenv - managing Python versions and dependencies

Pyenv is a tool that allows installing and managing several python versions and environments for different projects with their own set of dependencies. This is useful when having multiple projects using python.

pyenv copies python versions, flavors and environments into a local folder which then can be selected from a directory using shims.

Read more.

Installing

See https://github.com/yyuu/pyenv-installer

$ curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash

Configuring

pyenv install 3.6.2  # installs a new python version (-l to list all possibilities first after pyenv update)
pyenv virtualenvs  #shows you the list of existing virtualenvs
pyenv version  #shows python version that will be applied to the newly created venv
pyenv virtualenv [2.7] venv-name  # creates new venv with optional specific version
pyenv local 3.6.2  # associate this folder with a version  without a virtualenv
pyenv local venv-name  # associates the new venv with the directory

Reference: https://github.com/yyuu/pyenv/blob/master/COMMANDS.md

Updating

# check for new python versions and flavors (check with pyenv install -l)
pyenv update
# check for outdated python pip dependencies:
pip list --outdated

# update all pip requirements:
pip freeze --local | grep -v '^\-e' | cut -d = -f 1  | xargs pip install -U


Using Pyenv with Blender

  • Install the Python version that Blender currently requires and setup a virtual environment for it:
pyenv install 3.6.2
pyenv virtualenv 3.6.2 venv-blender
pyenv local venv-blender # run from the build directory
  • Install Blender's Python dependencies in the new virtual environment:
pip install numpy requirements
  • Set the path for the pyenv python directory before running CMake:

Blender's cmake configuration will fail if it does not find Python 3.6, so setting the path is useful if the OS doesn't have Python3. If the configuration already run once, then the values can simply be changed.

export PYTHON_ROOT_DIR=$HOME/.pyenv/versions/3.6.2

This is an example for the final values, notice that the paths refer the venv for the installed packages, otherwise they refer the generic python version:

PYTHON_EXECUTABLE:FILEPATH=/home/stitch/.pyenv/versions/3.6.2/bin/python3.6m
PYTHON_INCLUDE_CONFIG_DIR:PATH=/home/stitch/.pyenv/versions/3.6.2/include/python3.6m
PYTHON_INCLUDE_DIR:PATH=/home/stitch/.pyenv/versions/3.6.2/include/python3.6m
PYTHON_LIBPATH:PATH=/home/stitch/.pyenv/versions/3.6.2/lib
PYTHON_LIBRARY:FILEPATH=/home/stitch/.pyenv/versions/3.6.2/lib/libpython3.6m.a
PYTHON_LINKFLAGS:STRING=-Xlinker -export-dynamic
PYTHON_VERSION:STRING=3.6
PYTHON_NUMPY_PATH:PATH=/home/stitch/.pyenv/versions/venv-blender/lib64/python3.6/site-packages
PYTHON_NUMPY_INCLUDE_DIRS:PATH=/home/stitch/.pyenv/versions/venv-blender/lib64/python3.6/site-packages/numpy/core/include
PYTHON_REQUESTS_PATH:PATH=/home/stitch/.pyenv/versions/venv-blender/lib64/python3.6/site-packages
PYTHON_SITE_PACKAGES:FILEPATH=/home/stitch/.pyenv/versions/venv-blender/lib64/python3.6/site-packages