在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 ...
随机推荐
- Java.Annotations
Annotation 0. Annotation Tricks http://developer.android.com/reference/java/lang/annotation/Annotati ...
- linux执行系统命令时挂起
现象:使用mock构建时出现挂起现象 1.排除内存不足和构建工作空间所在磁盘分区不足情形: 2.执行任何系统命令异常卡顿 原因: 1.系统根分区空间严重不足: 解决办法: 清理根分区无用文件 1> ...
- RavenDb使用
在Raven中查询数据,查询条件必须在index中. 如果查询条件不在index中就会出现如下异常 var query = session.DynamicIndexQuery<ServicePr ...
- BZOJ 1227 [SDOI2009]虔诚的墓主人 - 扫描线
Solution 离散化 扫描线, 并用 $rest[i]$ 和 $cnt[i]$ 记录 第$i$列 总共有 $cnt[i]$棵常青树, 还有$rest[i]$ 没有被扫描到. 那么 第$i$ 列的方 ...
- Vuebnb 一个用 vue.js + Laravel 构建的全栈应用
今年我一直在写一本新书叫全栈Vue网站开发:Vue.js,Vuex和Laravel.它会在Packt出版社在2018年初出版. 这本书是围绕着一个案例研究项目,Vuebnb,简单克隆Airbnb.在这 ...
- Notepad++语言格式设置,自定义扩展名关联文件格式
简单粗暴--直接上图
- js 正则表达式,匹配邮箱/手机号/用户名
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Flex 得到一个对象的所有属性
var obj:Object =..... ///需要处理的对象 fieldname:Array = ObjectUtil.getClassInfo(obj)["properties&quo ...
- 449. Serialize and Deserialize BST
https://leetcode.com/problems/serialize-and-deserialize-bst/#/description Serialization is the proce ...
- Java:斐波那契数列
斐波那契数列指的是这样一个数列 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,377,610,987,1597,2584,4181,6765,10 ...