slow-starter

なにをやるにもslow start……。

python_028 pyenv virtualenv(2)

環境構築

  • 同一バージョンで複数の環境を設定できる仮想環境が作れるらしい。

pyenv virtualenv 設定

  • 複数バージョンのpython名前付き実行環境を、併用可能になる。
$ git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
$ echo '### pyenv virtualenv settings'       >> ~/.bashrc
$ echo 'eval "$(pyenv virtualenv-init -)"'   >> ~/.bashrc

pyenv virtualenv 利用

## インストール済みバージョン一覧表示
$ pyenv versions

## 利用可能なバージョン一覧表示
$ pyenv install -l

## 特定バージョン(N.N.N)インストール
$ pyenv install   N.N.N

## 特定バージョン(N.N.N)を利用して、特定の名前(hogehoge)の仮想環境を構築
$ pyenv virtualenv N.N.N hogehoge

## 特定の名前(hogehoge)を利用する
$ pyenv global hogehoge      # 全体設定として特定バージョンを利用
$ rm ~/.pyenv/version        # 解除

$ pyenv local  hogehoge      # 特定ディレクトリで特定バージョンを利用
$ pyenv local --unset        # 解除

$ pyenv shell  hogehoge      # シェル内で特定バージョンを利用
$ pyenv shell --unset        # 解除

## 特定の名前(hogehoge)の環境をアンインストール
$ pyenv uninstall hogehoge

pyenv vritualenv --help情報

$ pyenv virtualenv --help
Usage: pyenv virtualenv [-f|--force] [VIRTUALENV_OPTIONS] [version] <virtualenv-name>
       pyenv virtualenv --version
       pyenv virtualenv --help

  -f/--force       Install even if the version appears to be installed already

参考情報

python_027 pyenv virtualenv(1)

環境構築

  • 仮想環境を利用して構築すると良いらしい。

pyenv 設定

  • 複数バージョンのpython実行環境を利用可能になる。
$ git clone https://github.com/yyuu/pyenv.git ~/.pyenv
$ echo '### pyenv settings'                  >> ~/.bashrc
$ echo 'export PYENV_ROOT="$HOME/.pyenv"'    >> ~/.bashrc
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(pyenv init -)"'              >> ~/.bashrc

pyenv 利用

## インストール済みバージョン一覧表示
$ pyenv versions

## 利用可能なバージョン一覧表示
$ pyenv install -l

## 特定バージョン(N.N.N)インストール
$ pyenv install   N.N.N

## 特定バージョン(N.N.N)を利用する
$ pyenv global N.N.N         # 全体設定として特定バージョンを利用
$ rm ~/.pyenv/version        # 解除

$ pyenv local  N.N.N         # 特定ディレクトリで特定バージョンを利用
$ pyenv local --unset        # 解除

$ pyenv shell  N.N.N         # シェル内で特定バージョンを利用
$ pyenv shell --unset        # 解除

## 特定バージョン(N.N.N)のアンインストール
$ pyenv uninstall N.N.N

pyenv help情報

$ pyenv help
Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
   --version   Display the version of pyenv
   activate    Activate virtual environment
   commands    List all available pyenv commands
   deactivate   Deactivate virtual environment
   exec        Run an executable with the selected Python version
   global      Set or show the global Python version(s)
   help        Display help for a command
   hooks       List hook scripts for a given pyenv command
   init        Configure the shell environment for pyenv
   install     Install a Python version using python-build
   local       Set or show the local application-specific Python version(s)
   prefix      Display prefix for a Python version
   rehash      Rehash pyenv shims (run this after installing executables)
   root        Display the root directory where versions and shims are kept
   shell       Set or show the shell-specific Python version
   shims       List existing pyenv shims
   uninstall   Uninstall a specific Python version
   version     Show the current Python version(s) and its origin
   version-file   Detect the file that sets the current pyenv version
   version-name   Show the current Python version
   version-origin   Explain how the current Python version is set
   versions    List all Python versions available to pyenv
   virtualenv   Create a Python virtualenv using the pyenv-virtualenv plugin
   virtualenv-delete   Uninstall a specific Python virtualenv
   virtualenv-init   Configure the shell environment for pyenv-virtualenv
   virtualenv-prefix   Display real_prefix for a Python virtualenv version
   virtualenvs   List all Python virtualenvs found in `$PYENV_ROOT/versions/*'.
   whence      List all Python versions that contain the given executable
   which       Display the full path to an executable

See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/pyenv/pyenv#readme

参考情報

vim boolean

booleanの確認

#!/usr/bin/env python3
# False is False
print("False:\t",bool(False))
# True is True
print("True:\t",bool(True))
# 0 is False
print("0:\t",bool(0))
# 1.. is True
print("1:\t",bool(1))
# -1.. is True
print("-1:\t",bool(-1))
# None is False
print("None:\t",bool(None))
$./test.py
False:   False
True:    True
0:       False
1:       True
-1:      True
None:    False