在Ubuntu上安装pyenv
因为找到一个域名枚举的脚本使用Python3编写的,而我一直习惯的是使用Python2.7,在自己的Windows7上再安装个Python怕混了,于是想着在VPS上装个Python的版本管理工具,也方便自己以后测试,想到了pyenv(之前的是pythonbrew但是已经不在更新了,都是同一个作者),在GitHub上的链接为:https://github.com/yyuu/pyenv
安装pyenv:
$ 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
|
1
2
3
4
5
6
7
8
9
|
$ cd
$ 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
|
安装Python:
查看可安装版本列表:
$ pyenv install –list
安装指定版本:
$ pyenv install 3.4.1
该命令会从github上下载python的源代码,并解压到/tmp目录下,然后在/tmp中执行编译安装工作。编译过程依赖一些其他的库文件,若库文件不能满足,则编译错误,需要重新下载、编译。。。(常见编译问题解决方法:https://github.com/yyuu/pyenv/wiki/Common-build-problems)
已知的一些需要预先安装的库包括:
- readline readline-devel readline-static
- openssl openssl-devel openssl-static
- sqlite-devel
- bzip2-devel bzip2-libs
在所有python依赖库都安装好的情况下,python的安装很顺利(我在两个VPS上分别装的时候,一个非常顺利,另一个则总是出问题)。
更新数据库
安装完成之后需要对数据库进行更新:
$ pyenv rehash
查看当前已安装的python版本
$ pyenv versions
* system (set by /export/root/.pyenv/version)
3.4.1
其中的星号表示使用的是系统自带的python。
设置全局的python版本
$ pyenv global 3.4.1
$ pyenv versions
system
* 3.4.1 (set by /export/root/.pyenv/version)
当前全局的python版本已经变成了3.4.1。也可以使用pyenv local或pyenv shell临时改变python版本(重新登录后失效)。
确认python版本:
$ python
Python 2.7.3 (default, Feb 27 2014, 20:00:17)
[GCC 4.6.3] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>>
使用python:
输入python即可使用新版本的python;
系统命令会以/usr/bin/python的方式直接调用老版本的python;
使用pip安装第三方模块时会安装到~/.pyenv/versions/3.4.1下,不会和系统模块发生冲突。
———————–
参考文章:
https://github.com/yyuu/pyenv#installation
http://seisman.info/python-pyenv.html
———————–
附上安装过程中出现的一些问题及其解决方法:
$ pyenv install 3.4.1 #这里选择目前为止最新的Python3.4.1
……
checking whether the C compiler works… no
configure: error: in `/tmp/python-build.20140621173243.14345/Python-3.4.1′:
configure: error: C compiler cannot create executables
|
1
|
# apt-get install libc6-dev gcc
|
然后再执行:
Downloading Python-3.4.1.tgz...
-> http://yyuu.github.io/pythons/8d007e3ef80b128a292be101201e75dec5480e5632e994771e7c231d17720b66
Installing Python-3.4.1...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
Please consult to the Wiki page to fix the problem.
https://github.com/yyuu/pyenv/wiki/Common-build-problems
BUILD FAILED
Inspect or clean up the working tree at /tmp/python-build.20140621173821.18496
Results logged to /tmp/python-build.20140621173821.18496.log
Last 10 log lines:
(cd /root/.pyenv/versions/3.4.1/share/man/man1; ln -s python3.4.1 python3.1)
if test "xupgrade" != "xno" ; then
case upgrade in
upgrade) ensurepip="--upgrade" ;;
install|*) ensurepip="" ;;
esac;
./python -E -m ensurepip
$ensurepip --root=/ ;
fi
Ignoring ensurepip failure: pip 1.5.6 requires SSL/TLS
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# pyenv install 3.4.1
Downloading Python-3.4.1.tgz...
-> http://yyuu.github.io/pythons/8d007e3ef80b128a292be101201e75dec5480e5632e994771e7c231d17720b66
Installing Python-3.4.1...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
Please consult to the Wiki page to fix the problem.
https://github.com/yyuu/pyenv/wiki/Common-build-problems
BUILD FAILED
Inspect or clean up the working tree at /tmp/python-build.20140621173821.18496
Results logged to /tmp/python-build.20140621173821.18496.log
Last 10 log lines:
(cd /root/.pyenv/versions/3.4.1/share/man/man1; ln -s python3.4.1 python3.1)
if test "xupgrade" != "xno" ; then
case upgrade in
upgrade) ensurepip="--upgrade" ;;
install|*) ensurepip="" ;;
esac;
./python -E -m ensurepip
$ensurepip --root=/ ;
fi
Ignoring ensurepip failure: pip 1.5.6 requires SSL/TLS
|
安装bzip2和OpenSSL库依赖(因为Python3.4.1这个版本修复了之前的Heart Bleed那个漏洞,所以OpenSSL的版本和之前的版本不同,需要重新安装最新版本的OpenSSL,这是我估计的,因为在Python的官方主页上面看到Python3.4.1这个版本修复了HeartBleed漏洞)
试试再运行一遍基础库依赖的安装命令:
|
1
|
# apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm
|
再执行安装命令,果然就没问题了:
Downloading Python-3.4.1.tgz...
-> http://yyuu.github.io/pythons/8d007e3ef80b128a292be101201e75dec5480e5632e994771e7c231d17720b66
Installing Python-3.4.1...
Installed Python-3.4.1 to /root/.pyenv/versions/3.4.1
|
1
2
3
4
5
|
# pyenv install 3.4.1
Downloading Python-3.4.1.tgz...
-> http://yyuu.github.io/pythons/8d007e3ef80b128a292be101201e75dec5480e5632e994771e7c231d17720b66
Installing Python-3.4.1...
Installed Python-3.4.1 to /root/.pyenv/versions/3.4.1
|
在Ubuntu上安装pyenv的更多相关文章
- 在ubuntu上安装pyenv出现的问题
1.安装完pyenv时,并没有出现问题.但在安装python3.6.1时报错: ERROR: The Python ssl extension was not compiled. Missing th ...
- 在Ubuntu上安装pyenv 相关问题Common build problems
Requirements: Ubuntu/Debian: sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libb ...
- [异常解决] ubuntu上安装JLink驱动遇到的坑及给后来者的建议
一.前言 最近将整个电脑格式化,改成了linux操作系统 希望这样能让自己在一个新的世界探索技术.提升自己吧- win上的工具用多了,就不想变化了- 继上一篇<ubuntu上安装虚拟机遇到的问题 ...
- Ubuntu上安装Robomongo及添加到启动器
到目前为止,Robomongo仍是MongoDB最好的客户端管理工具,如需在Ubuntu上安装Robomongo,可直接从官网下载.tar.gz压缩包进行解压,然后直接运行bin目录下的robomon ...
- 在 Ubuntu 上安装 Android Studio
在 Ubuntu 上安装 Android Studio http://www.linuxidc.com/Linux/2013-05/84812.htm 打开terminal,输入以下命令 sudo a ...
- Ubuntu上安装Karma失败对策
在Ubuntu上安装Karma遇到超时 timeout 错误.Google了一下,国外的码农给了一个快捷的解决方案,实测可行,贴在这里: sudo apt-get install npm nodejs ...
- 在Ubuntu上安装LAMP服务器
1.安装Ubuntu上安装LAMP apt-get install lamp-server^ 2.安装过程中设置MySql密码 3.测试 创建index.php var/www/html/index. ...
- [译]How to Setup Sync Gateway on Ubuntu如何在ubuntu上安装sync-gateway
参考文章https://hidekiitakura.com/2015/03/21/how-to-setup-sync-gateway-on-ubuntudigitalocean/ 在此对作者表示感谢 ...
- 在Ubuntu上安装JDK、Ant、Jmeter和Jenkins
一.前期准备 1. 在win7下载VMware.Ubuntu(用迅雷下比较快) 2. 安装完VMware后新建虚拟机,选择iso: 3. 具体配置参考如下,至此Ubantu安装完成 二.在Ubuntu ...
随机推荐
- UVALive - 3266 (贪心) 田忌赛马
耳熟能详的故事,田忌赛马,第一行给出田忌的马的速度,第二行是齐王的马的速度,田忌赢一场得200,输一场失去200,平局不得也不失,问最后田忌最多能得多少钱? 都知道在故事里,田忌用下等马对上等马,中等 ...
- linux基础编程:IO模型:阻塞/非阻塞/IO复用 同步/异步 Select/Epoll/AIO(转载)
IO概念 Linux的内核将所有外部设备都可以看做一个文件来操作.那么我们对与外部设备的操作都可以看做对文件进行操作.我们对一个文件的读写,都通过调用内核提供的系统调用:内核给我们返回一个file ...
- spring配置遇到的问题
1.文档根元素 "beans" 必须匹配 DOCTYPE 根 "null" 这个原因是因为我自动扫描mapping.xml的文件路径设置错误,把它设置成spri ...
- apt install yum失败
解决办法:sudo apt-get update
- 软件测试基础Ⅲ(osi7层协议,测试模型,LoadRunner组件,软件质量模型)
osi7层开放式系统互连网络模型 1.物理层:主要定义物理设备标准,如网线的接口类型.光纤的接口类型.各种传输介质的传输速率等.它的主要作用是传输比特流(就是由1.0转化为电流强弱来进行传输,到达目的 ...
- 【Web】Sublime Text 3 安装+注册+汉化
Sublime Text 介绍 Sublime Text 是一个代码编辑器,也是HTML和散文先进的文本编辑器.Sublime Text是由程序员Jon Skinner于2008年1月份所开发出来,它 ...
- XML 解析的两种方法
申请博客有一段时间了,一直没有写些什么,今天写一下被遗忘的 xml,因为 ios 现在一般都用 JSON,但毕竟还有一部分老一些的服务器还会有 xml xml 格式的解析方式有两种 1.SAX解析: ...
- hibernate配置文件 连接数据库
http://jingyan.baidu.com/album/0320e2c1d4dd0b1b87507b38.html?picindex=12
- python的数字图像处理学习(1)
导入原有的测试图片,测试图片路径,和一些方法,显示出测试图像,测试图像路径. from skimage import io,data,data_dir img_rgb=data.chelsea() i ...
- java学习第六周
这是暑假学习的第六周,在这周我练习了老师给的例题,还是有一些地方看不懂,这周我对那些不懂的地方用看视频来进行解答,以及进行第二次复习. 下周我会对Java进行更加详细的复习,做好笔记,在LeetCod ...