在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 ...
随机推荐
- Thread中join()方法进行介绍
http://www.cnblogs.com/skywang12345/p/3479275.html https://blog.csdn.net/dabing69221/article/details ...
- 富文本编辑器--FCKEditor 上传图片
FCKEditor的最新版本已经更改名称为CKEditor: 1.在页面引入fckeditor目录下的fckeditor.js <script type="text/javascrip ...
- Linux惊群效应详解
Linux惊群效应详解(最详细的了吧) linux惊群效应 详细的介绍什么是惊群,惊群在线程和进程中的具体表现,惊群的系统消耗和惊群的处理方法. 1.惊群效应是什么? 惊群效应也有人 ...
- java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;
在Tomcat下部署应用时会报这个错误,参考以下这篇博客:http://blog.csdn.net/robinsonmhj/article/details/37653189,删除Tomcat目录下we ...
- Python数据库工具类MySQLdb使用
MySQLdb模块用于连接mysql数据库. 基本操作 # -*- coding: utf-8 -*- #mysqldb import time, MySQLdb ...
- generic_netlink 用法
参考资料: https://wiki.linuxfoundation.org/networking/generic_netlink_howto generic_netlink 框架 +-------- ...
- openssl_error_string()
其实已经成功了,openssl_error_string()一样会输出错误信息,忽略就好
- SCM_SVN_CVS
SCM_SVN_CVS SCM:一种用于记录并控制软件数据的工具.比如有:CVS(有过时趋势)和SVN(更加常用). 版本控制的概念: Respository:仓库 Workspace:工作台 Del ...
- eclipse打开出现Failed to create the java virtual machine
低配伤不起呀... 这个问题经常是由于创建JAVA 虚拟机时,内存不足导致的,怎么办呢? 1.找到这么个文件:eclipse.ini(在哪?与ECLIPSE.EXE在一起,在一起...) 2.修改里面 ...
- mybatis 插入数据并返回主键值
<insert id="insert" parameterType="com.pojo.TSubject" useGeneratedKeys=" ...