Ubuntu安裝pyenv實現python多版本控制

Ubuntu安裝pyenv實現python多版本控制

git clone git://github.com/yyuu/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
exec $SHELL -l

查看可安裝的版本python

pyenv install --list

好比安裝python2.7.14和python3.6.3版本linux

pyenv install 2.7.14 -v
pyenv install 3.6.3 -v

設置其爲全局pythongit

pyenv global 2.7.14 3.6.3

查看是否安裝成功github

ltq@lab:~$ python
Python 2.7.14 (default, Nov 25 2017, 23:00:16) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
ltq@lab:~$ python3
Python 3.6.3 (default, Nov 27 2017, 22:54:07) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

另外,每當你增刪了 Python 版本或帶有可執行文件的包(如 pip)之後,都應該執行一次本shell

pyenv rehash

更多命令參考pyenv-github,或者ubuntu

ltq@lab:~$ pyenv -h
Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
   commands    List all available pyenv commands
   local       Set or show the local application-specific Python version
   global      Set or show the global Python version
   shell       Set or show the shell-specific Python version
   install     Install a Python version using python-build
   uninstall   Uninstall a specific Python version
   rehash      Rehash pyenv shims (run this after installing executables)
   version     Show the current Python version and its origin
   versions    List all Python versions available to pyenv
   which       Display the full path to an executable
   whence      List all Python versions that contain the given executable

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

https://github.com/pyenv/pyenvbash

相關文章
相關標籤/搜索