python 环境管理器pyenv 命令

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

写500 lines or less的时候需要用到python 3.4更新的selectors库,不得不安装一个pyenv(很好记,python environment)

原味来自官方文档:https://github.com/yyuu/pyenv/blob/master/COMMANDS.md#command-reference

(对于mac版本的特别注意:使用之前要加上

if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
来配置terminal

)

pyenv local

设置当前(Sets a local application-specific Python version)python版本:

$ pyenv local 2.7.6

pyenv local 可以查看当前版本

pyenv local (advanced)

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 --versionPython 2.7.6$ python2.7 --versionPython 2.7.6$ python3.3 --versionPython 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 --versionPython 3.3.3$ python2.7 --versionPython 2.7.6$ python3.3 --versionPython 3.3.3
(在前面加上版本名即可)

pyenv global

(改变python的全局版本)

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.(如果后面不加上版本号,那么就输出当前的python版本)

pyenv global (advanced)

(与上文 pyenv local 的advanced部分相同)

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 --versionPython 2.7.6$ python2.7 --versionPython 2.7.6$ python3.3 --versionPython 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 --versionPython 3.3.3$ python2.7 --versionPython 2.7.6$ python3.3 --versionPython 3.3.3

pyenv shell

(创建一个pyenv的shell,这个shell的版本和local或者global的版本不冲突)

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

pyenv rehash

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
(在你安装一个新版本的python之后使用)

pyenv install

(使用pyenv安装不同的python版本)

Install a Python version (using python-build).

Usage: pyenv install [-f] [-kvp] <version>       pyenv install [-f] [-kvp] <definition-file>       pyenv install -l|--list  -l/--list             List all available versions  -f/--force            Install even if the version appears to be installed already  -s/--skip-existing    Skip the installation if the version appears to be installed already  python-build options:  -k/--keep        Keep source tree in $PYENV_BUILD_ROOT after installation                   (defaults to $PYENV_ROOT/sources)  -v/--verbose     Verbose mode: print compilation status to stdout  -p/--patch       Apply a patch from stdin before building  -g/--debug       Build a debug version

To list the all available versions of Python, including Anaconda, Jython, pypy, and stackless, use:

$ pyenv install --list

Then install the desired versions:

$ 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)

pyenv uninstall

Uninstall a specific Python version.

Usage: pyenv uninstall [-f|--force] <version>   -f  Attempt to remove the specified version without prompting       for confirmation. If the version does not exist, do not       display an error message.

pyenv version

Displays the currently active Python version, along with information on how it was set.

$ pyenv version2.7.6 (set by /home/yyuu/.pyenv/version)

pyenv whence

Lists all Python versions with the given command installed.

$ pyenv whence 2to32.6.82.7.63.3.3

           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow

这里写图片描述

猜你喜欢

转载自blog.csdn.net/qq_43680117/article/details/84033891