pyenv的使用
开始想使用virtual实现不同的版本的py隔离,然后发现不太方便,然后发现了这货。
pyenv安装(ubuntu环境
➜ ~ git clone git://github.com/yyuu/pyenv.git ~/.pyenv
Cloning into '/home/wang/.pyenv'...
remote: Counting objects: 12600, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 12600 (delta 7), reused 0 (delta 0), pack-reused 12583
Receiving objects: 100% (12600/12600), 2.24 MiB | 47.00 KiB/s, done.
Resolving deltas: 100% (8749/8749), done.
Checking connectivity... done.
➜ ~ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
➜ ~ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
➜ ~ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
➜ ~ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
➜ ~ echo 'eval "$(pyenv init -)"' >> ~/.bashrc
➜ ~ echo 'eval "$(pyenv init -)"' >> ~/.zshrc
➜ ~ exec $SHELL -l
注:如果你没有使用zsh,那么zshrc相关的都可以不用执行
验证安装是否成功:
➜ ~ pyenv
commands help local shell --version version-name which
completions hooks prefix shims version-file version-origin
exec init rehash uninstall version-file-read versions
global install root version version-file-write whence
输入pyenv然后tab会出现各种补全的选项
pyenv的基本使用:
➜ ~ pyenv --version # pyenv版本
pyenv 20160422-3-gd0fae57
➜ ~ pyenv versions # 当前py版本信息,如果装了其他版本那么会显示多个
* system (set by /home/wang/.pyenv/version)
➜ ~
➜ ~ pyenv help
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/yyuu/pyenv#readme
➜ ~ pyenv init # 如果输入pyenv之后使用tab不补全,可以使用这个命令初始化一下,然后就可以使用补全命令了
# Load pyenv automatically by appending
# the following to ~/.zshrc: eval "$(pyenv init -)"
显示可以安装的列表
➜ ~ pyenv install -l # 可以安装的版本,此处只列举几个(因为实在是太多了啊
Available versions:
2.1.3
2.2.3
2.3.7
2.4
2.4.1
pyenv安装py
➜ ~ pyenv install 3.3.1 # install py3.3.1
Downloading Python-3.3.1.tgz...
-> http://www.python.org/ftp/python/3.3.1/Python-3.3.1.tgz
Installing Python-3.3.1...
patching file ./Modules/readline.c
Hunk #1 succeeded at 225 (offset -6 lines).
Hunk #2 succeeded at 759 (offset -14 lines).
Hunk #3 succeeded at 812 (offset -14 lines).
Hunk #4 succeeded at 870 (offset -14 lines).
Hunk #5 succeeded at 918 with fuzz 2 (offset -25 lines).
patching file ./Lib/ssl.py
Hunk #2 succeeded at 609 (offset -40 lines).
patching file ./Modules/_ssl.c
Hunk #1 succeeded at 1683 (offset -63 lines).
Hunk #2 succeeded at 2751 (offset -93 lines).
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?
Installing pip from https://bootstrap.pypa.io/get-pip.py...
2016-05-08 21:29:03 URL:https://bootstrap.pypa.io/get-pip.py [1522812/1522812] -> "-" [1]
Installed Python-3.3.1 to /home/wang/.pyenv/versions/3.3.1 ➜ ~ pyenv rehash # 更新本地数据库
➜ ~
➜ ~ pyenv versions # 查看本机版本信息
* system (set by /home/wang/.pyenv/version)
3.3.1
global, shell, local的使用
➜ ~ pyenv versions
* system (set by /home/wang/.pyenv/version)
3.3.1
➜ ~
➜ ~ python --version
Python 2.7.6
➜ ~
➜ ~ pyenv global 3.3.1 # 更改本机版本,重启不会造成再次更改
➜ ~
➜ ~ python --version
Python 3.3.1
➜ ~
➜ ~ pyenv local system # 更改本地的版本,只是临时生效,重启什么的会恢复系统版本
➜ ~
➜ ~ python --version
Python 2.7.6
➜ ~
➜ ~ python shell 3.3.1 # 更改本shell的版本,临时生效,优先级高于global,local的也高于global,都是临时生效
python: can't open file 'shell': [Errno 2] No such file or directory
➜ ~ pyenv shell 3.3.1
➜ ~ pyenv versions
system
* 3.3.1 (set by PYENV_VERSION environment variable)
➜ ~
➜ ~ python
Python 3.3.1 (default, May 8 2016, 21:27:17)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
global, loacl优先级比较
➜ ~ pyenv global 3.3.1 # 这个例子可以看出优先级
➜ ~ pyenv --version
pyenv 20160422-3-gd0fae57
➜ ~ pyenv versions
* system (set by /home/wang/.python-version)
3.3.1
➜ ~ pyenv local 3.3.1
➜ ~ pyenv versions
system
* 3.3.1 (set by /home/wang/.python-version)
➜ ~ pyenv shell system
➜ ~ pyenv versions
* system (set by PYENV_VERSION environment variable)
3.3.1
➜ ~ python global
python: can't open file 'global': [Errno 2] No such file or directory
➜ ~ pyenv global system
➜ ~ pyenv versions
* system (set by PYENV_VERSION environment variable)
3.3.1
pyenv和virtualenv的搭配使用
➜ ~ cd .pyenv/plugins # 安装virtualenv插件
➜ plugins git:(master) git clone https://github.com/yyuu/pyenv-virtualenv.git
Cloning into 'pyenv-virtualenv'...
remote: Counting objects: 1781, done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 1781 (delta 8), reused 0 (delta 0), pack-reused 1762
Receiving objects: 100% (1781/1781), 518.17 KiB | 46.00 KiB/s, done.
Resolving deltas: 100% (1208/1208), done.
Checking connectivity... done.
➜ plugins git:(master) pyenv virtualenv 3.3.1 my_pro_3.3.1 # 创建3.3.1版本虚拟环境
Installing pip from https://bootstrap.pypa.io/get-pip.py...
2016-05-08 21:42:21 URL:https://bootstrap.pypa.io/get-pip.py [1522812/1522812] -> "-" [1]
Collecting pip
Using cached pip-8.1.1-py2.py3-none-any.whl
Collecting setuptools
Using cached setuptools-21.0.0-py2.py3-none-any.whl
Collecting wheel
Using cached wheel-0.29.0-py2.py3-none-any.whl
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-8.1.1 setuptools-21.0.0 wheel-0.29.0
➜ plugins git:(master) pyenv virtualenvs # 显示环境,为什么有2个我有点不太懂
3.3.1/envs/my_pro_3.3.1 (created from /home/wang/.pyenv/versions/3.3.1)
my_pro_3.3.1 (created from /home/wang/.pyenv/versions/3.3.1)
➜ plugins git:(master) pyenv versions
* system (set by PYENV_VERSION environment variable)
3.3.1
3.3.1/envs/my_pro_3.3.1
my_pro_3.3.1
➜ plugins git:(master) pyenv activate 3.3.1/envs/my_pro_3.3.1 # 激活使用,有错误,可以重启shell Failed to activate virtualenv. Perhaps pyenv-virtualenv has not been loaded into your shell properly.
Please restart current shell and try again.
vitualenv的使用
➜ ~ pyenv activate 3.3.1/envs/my_pro_3.3.1 # 两个都可以进去
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(3.3.1/envs/my_pro_3.3.1) ➜ ~ pyenv deactivate
➜ ~ pyenv activate my_pro_3.3.1
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(my_pro_3.3.1) ➜ ~ pyenv deactivate # 离开
➜ ~ rm -rf .pyenv/versions/3.3.1 # 删除
➜ ~ pyenv versions # 看来其中一个应该是我们安装的版本信息
pyenv: version `3.3.1' is not installed (set by /home/wang/.python-version)
system
➜ ~ rm -rf .pyenv/versions/my_pro_3.3.1 # 当安装了virtualenv插件之后就会都显示,相当于也使用了virtualenv
➜ ~ pyenv versions # 实现的,但是没有安装就没有显示
pyenv: version `3.3.1' is not installed (set by /home/wang/.python-version)
system
参考:
http://www.it165.net/pro/html/201405/13603.html
http://seisman.info/python-pyenv.html
https://github.com/comynli/pybooklet/blob/master/install.md
pyenv的使用的更多相关文章
- MacOS下Python的多版本管理(pyenv)
与windows下设置绝对路径不同,pyenv使用了一种更优雅的方式来管理Python的版本.pyenv通过在$PATH的最前面插入一个垫片路径(shims),例如:~/.pyenv/shims:/u ...
- Python实用环境pyenv搭建教程
实验系统:kubuntu-15.10-desktop-amd64 关于pyenv的介绍:一般在操作系统中我们会安装多个Python版本,在*nix系统中一般默认就自带了Python2与Python3两 ...
- Ubuntu下安装Pyenv不成功,求指教
虚拟机:VMware12.0 操作系统:Ubuntu16.04 LTS (新安装系统) 已经按照网上的步骤: 1.安装git: $sudo apt-get install git 2.安装依赖包: $ ...
- pyenv 使用简介
pyenv 是一个 python 版本管理工具,可以方便用户在不同的 python 版本间切换,例如我的电脑里默认的 python 是 2.6, 但我还想装 2.7 3.5 等.另有一个名为 pyen ...
- Python多版本共存之pyenv
经常遇到这样的情况: 系统自带的Python是2.6,自己需要Python 2.7中的某些特性: 系统自带的Python是2.x,自己需要Python 3.x: 此时需要在系统中安装多个Python, ...
- pyenv ipython jupyter
pyenv pyenv 依赖安装 yum -y install git gcc make patch zlib-devel gdbm-devel openssl-devel sqlite-devel ...
- Ubuntu14.04通过pyenv配置多python
参考链接: https://github.com/yyuu/pyenv-virtualenv https://github.com/yyuu/pyenv http://seisman.info/pyt ...
- pyenv 以及 virtualenv
244 pyenv global 3.5.1 245 which python 246 python 247 pip install virtualenv 248 ls 249 pwd 250 ls ...
- CentOS下用pyenv 和 virtualenv 搭建单机多版本python 虚拟开发环境
安装 系统环境:CentOS 6.5 安装依赖 yum -y install gcc gcc-c++ make git patch openssl-devel zlib-devel readline- ...
随机推荐
- Apache POI 实现对 Excel 文件读写
1. Apache POI 简介 Apache POI是Apache软件基金会的开放源码函式库. 提供API给Java应用程序对Microsoft Office格式档案读和写的功能. 老外起名字总是很 ...
- Expression Blend4经验分享:文字公告无缝循环滚动效果
这次分享一个类似新闻公告板的无缝循环滚动效果,相信很多项目都会应用到这个效果.之前我也百度了一下,网上的一些Silverlight的文字或图片滚动效果,都是一次性滚动的,如果要做到无缝循环滚动,多数要 ...
- 别再迷信 zepto 了
希望网上公开课的老师们不要再讲移动端网页用zepto了,坑了无数鸟啊 ~~~. 1.自己/公司/项目组所写和所积累(网上下的)的js函数都是以jQuery插件的写法来写的,如果要换到zepto上的话那 ...
- PHP中WEB典型应用技术
主要讲5个方面: PHP与web页面的交互:表单传值,文件的上传与下载 http协议 PHP的会话技术:cookie和session PHP的图像技术:GD库,图像的常见的制作和操作,验证码,二维码, ...
- 【监控】WebServer入库与缓存更新代码优化小计
问题描述: 通过WebServer将监控数据入库到Hbase,在入库之前需要将指标与ip的列表更新到缓存中,以便前台页面随时选择查看.前两天上了一些新用户导致负载增加,逐渐发现某些用户的监控场景出现丢 ...
- ASP.NET Web API 安全验证之摘要(Digest)认证
在基本认证的方式中,主要的安全问题来自于用户信息的明文传输,而在摘要认证中,主要通过一些手段避免了此问题,大大增加了安全性. 1.客户端匿名的方式请求 (无认证) HTTP/ Unauthorized ...
- 学习服务端JavaScript这个有名的Node.js
没接触过,试着简单学一下,从头开始: 参照这个教程:https://github.com/alsotang/node-lessons/tree/master/lesson0 一.搭建环境: 1.搭建N ...
- shell note
1 输出重定向:ll > aaa 将输出内容 添加到aaa文件中 ll >> aaa将输出内容追加到aaa中 ll &>> abc 将输出内容不论正确或错误都保存 ...
- Java之构造器的作用
我总是要把构造器和方法混淆,后来发现, 方法,实际上,是需要用于执行java代码的,而构造器, 构造器,,,是一个类的实例!! 为什么呢? 类的实例,我们需要用类来创建对象,进而访问其属性,因为实例是 ...
- Rootkit Hunter恶意程序查杀
恶意程序,恶意代码检测 下载:https://pkgs.org/search/rkhunter 安装:rpm -ivh rkunter* Installed: #需要先安装 lsof.x86_64 ...