pyenv/COMMANDS.md

266 lines
6.5 KiB
Markdown
Raw Normal View History

2014-03-20 09:13:15 -04:00
# Command Reference
Like `git`, the `pyenv` command delegates to subcommands based on its
first argument.
The most common subcommands are:
* [`pyenv commands`](#pyenv-commands)
2014-03-20 09:20:20 -04:00
* [`pyenv local`](#pyenv-local)
* [`pyenv global`](#pyenv-global)
* [`pyenv shell`](#pyenv-shell)
* [`pyenv install`](#pyenv-install)
* [`pyenv uninstall`](#pyenv-uninstall)
2014-03-20 09:20:20 -04:00
* [`pyenv versions`](#pyenv-versions)
* [`pyenv version`](#pyenv-version)
* [`pyenv rehash`](#pyenv-rehash)
* [`pyenv which`](#pyenv-which)
* [`pyenv whence`](#pyenv-whence)
2014-03-20 09:13:15 -04:00
## `pyenv commands`
Lists all available pyenv commands.
2014-03-20 09:20:20 -04:00
## `pyenv local`
2014-03-20 09:13:15 -04:00
Sets a local application-specific Python version by writing the version
name to a `.python-version` file in the current directory. This version
overrides the global version, and can be overridden itself by setting
the `PYENV_VERSION` environment variable or with the `pyenv shell`
command.
$ pyenv local 2.7.6
When run without a version number, `pyenv local` reports the currently
configured local version. You can also unset the local version:
$ pyenv local --unset
Previous versions of pyenv stored local version specifications in a
file named `.pyenv-version`. For backwards compatibility, pyenv will
read a local version specified in an `.pyenv-version` file, but a
`.python-version` file in the same directory will take precedence.
2014-03-20 09:20:20 -04:00
### `pyenv local` (advanced)
2014-03-20 09:13:15 -04:00
You can specify multiple versions as local Python at once.
Let's say if you have two versions of 2.7.6 and 3.3.3. If you prefer 2.7.6 over 3.3.3,
$ pyenv local 2.7.6 3.3.3
$ pyenv versions
system
* 2.7.6 (set by /Users/yyuu/path/to/project/.python-version)
* 3.3.3 (set by /Users/yyuu/path/to/project/.python-version)
$ python --version
Python 2.7.6
$ python2.7 --version
Python 2.7.6
$ python3.3 --version
Python 3.3.3
or, if you prefer 3.3.3 over 2.7.6,
$ pyenv local 3.3.3 2.7.6
$ pyenv versions
system
* 2.7.6 (set by /Users/yyuu/path/to/project/.python-version)
* 3.3.3 (set by /Users/yyuu/path/to/project/.python-version)
venv27
$ python --version
Python 3.3.3
$ python2.7 --version
Python 2.7.6
$ python3.3 --version
Python 3.3.3
2014-03-20 09:20:20 -04:00
## `pyenv global`
2014-03-20 09:13:15 -04:00
Sets the global version of Python to be used in all shells by writing
the version name to the `~/.pyenv/version` file. This version can be
overridden by an application-specific `.python-version` file, or by
setting the `PYENV_VERSION` environment variable.
$ pyenv global 2.7.6
The special version name `system` tells pyenv to use the system Python
(detected by searching your `$PATH`).
When run without a version number, `pyenv global` reports the
currently configured global version.
2014-03-20 09:20:20 -04:00
### `pyenv global` (advanced)
2014-03-20 09:13:15 -04:00
You can specify multiple versions as global Python at once.
Let's say if you have two versions of 2.7.6 and 3.3.3. If you prefer 2.7.6 over 3.3.3,
$ pyenv global 2.7.6 3.3.3
$ pyenv versions
system
* 2.7.6 (set by /Users/yyuu/.pyenv/version)
* 3.3.3 (set by /Users/yyuu/.pyenv/version)
$ python --version
Python 2.7.6
$ python2.7 --version
Python 2.7.6
$ python3.3 --version
Python 3.3.3
or, if you prefer 3.3.3 over 2.7.6,
$ pyenv global 3.3.3 2.7.6
$ pyenv versions
system
* 2.7.6 (set by /Users/yyuu/.pyenv/version)
* 3.3.3 (set by /Users/yyuu/.pyenv/version)
venv27
$ python --version
Python 3.3.3
$ python2.7 --version
Python 2.7.6
$ python3.3 --version
Python 3.3.3
2014-03-20 09:20:20 -04:00
## `pyenv shell`
2014-03-20 09:13:15 -04:00
Sets a shell-specific Python version by setting the `PYENV_VERSION`
environment variable in your shell. This version overrides
application-specific versions and the global version.
$ pyenv shell pypy-2.2.1
When run without a version number, `pyenv shell` reports the current
value of `PYENV_VERSION`. You can also unset the shell version:
$ pyenv shell --unset
Note that you'll need pyenv's shell integration enabled (step 3 of
the installation instructions) in order to use this command. If you
prefer not to use shell integration, you may simply set the
`PYENV_VERSION` variable yourself:
$ export PYENV_VERSION=pypy-2.2.1
2014-03-20 09:20:20 -04:00
### `pyenv shell` (advanced)
2014-03-20 09:13:15 -04:00
You can specify multiple versions via `PYENV_VERSION` at once.
Let's say if you have two versions of 2.7.6 and 3.3.3. If you prefer 2.7.6 over 3.3.3,
$ pyenv shell 2.7.6 3.3.3
$ pyenv versions
system
* 2.7.6 (set by PYENV_VERSION environment variable)
* 3.3.3 (set by PYENV_VERSION environment variable)
$ python --version
Python 2.7.6
$ python2.7 --version
Python 2.7.6
$ python3.3 --version
Python 3.3.3
or, if you prefer 3.3.3 over 2.7.6,
$ pyenv shell 3.3.3 2.7.6
$ pyenv versions
system
* 2.7.6 (set by PYENV_VERSION environment variable)
* 3.3.3 (set by PYENV_VERSION environment variable)
venv27
$ python --version
Python 3.3.3
$ python2.7 --version
Python 2.7.6
$ python3.3 --version
Python 3.3.3
## `pyenv install`
Install a Python version (using `python-build`).
## `pyenv uninstall`
Uninstall a specific Python version
2014-03-20 09:20:20 -04:00
## `pyenv versions`
2014-03-20 09:13:15 -04:00
Lists all Python versions known to pyenv, and shows an asterisk next to
the currently active version.
$ pyenv versions
2.5.6
2.6.8
* 2.7.6 (set by /home/yyuu/.pyenv/version)
3.3.3
jython-2.5.3
pypy-2.2.1
2014-03-20 09:20:20 -04:00
## `pyenv version`
2014-03-20 09:13:15 -04:00
Displays the currently active Python version, along with information on
how it was set.
$ pyenv version
2.7.6 (set by /home/yyuu/.pyenv/version)
2014-03-20 09:20:20 -04:00
## `pyenv rehash`
2014-03-20 09:13:15 -04:00
Installs shims for all Python binaries known to pyenv (i.e.,
`~/.pyenv/versions/*/bin/*`). Run this command after you install a new
version of Python, or install a package that provides binaries.
$ pyenv rehash
2014-03-20 09:20:20 -04:00
## `pyenv which`
2014-03-20 09:13:15 -04:00
Displays the full path to the executable that pyenv will invoke when
you run the given command.
$ pyenv which python3.3
/home/yyuu/.pyenv/versions/3.3.3/bin/python3.3
2014-03-20 09:20:20 -04:00
## `pyenv whence`
2014-03-20 09:13:15 -04:00
Lists all Python versions with the given command installed.
$ pyenv whence 2to3
2.6.8
2.7.6
3.3.3
2014-03-20 09:20:20 -04:00
## `pyenv install`
2014-03-20 09:13:15 -04:00
Part of [Python-build](https://github.com/yyuu/pyenv/tree/master/plugins/python-build), this installs versions of python
$ pyenv install 2.7.6
$ pyenv install 2.6.8
$ pyenv versions
system
2.6.8
* 2.7.6 (set by /home/yyuu/.pyenv/version)
2014-03-20 09:20:20 -04:00
## `pyenv install --list`
2014-03-20 09:13:15 -04:00
List available remote versions of Python, including Anaconda, Jython, pypy, and stackless
$ pyenv install --list