在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 ...
随机推荐
- widget jquery 理解
jquery ui 的所有组件都是基于一个简单,可重用的widget. 这个widget是jquery ui的核心部分,实用它能实现一致的API,创建有状态的插件,而无需关心插件的内部转换. $.wi ...
- Python 环境安装教程(Windows 10)
Python编程语言非常强大,非常容易上手,版本更新也不慢,在win10 x64中兼容性也很好,直接安装不需另外配置,虽然Python2和3有点异同.学习的话选择最新的 python 3.7.1版. ...
- BZOJ 4521 [CQOI2016]手机号码 - 数位DP
Description 在$[L, R]$找出有几个数满足两个条件 : 1 : 不同时含有$4$ 和 $8$ 2 : 至少有$3$个相邻的数相同 Solution 非常容易的数位DP, $pos$ 为 ...
- 记录点复习题目和linux学习
哈希怎么底层.key放数组哪部分里面 HashMap实际上是一个“链表散列”的数据结构,即数组和链表的结合体. 开网页怎么获取页面 linux 看进程的cpu 和内存占用率 看哪个端口被占用 ...
- 【UI测试】--帮助设施
- XML 解析的两种方法
申请博客有一段时间了,一直没有写些什么,今天写一下被遗忘的 xml,因为 ios 现在一般都用 JSON,但毕竟还有一部分老一些的服务器还会有 xml xml 格式的解析方式有两种 1.SAX解析: ...
- Codeforces 1106 简要题解
文章目录 A题 B题 C题 D题 E题 F题 传送门 A题 传送门 读错题还能过样例我给自己点个赞. 题意简述:给一个010101网格SSS,问满足Si,j=Si+1,j+1=Si+1,j−1=Si− ...
- pytorch总结
PyTorch 深度学习:60分钟快速入门 用例子学习 PyTorch 手把手教你用PyTorch从零搭建图像分类模型
- Win7 VS2013环境编译boost1_58_0
备忘,发现好多不常用的东西不记笔记再想用要重新花时间找,所以试着开始记笔记,写入博客吧. 首先去官网下最新的版本 http://www.boost.org/ 写本文时boost最新版本为1_58_0, ...
- c++中typedef、define、const、inline之间的区别
1.typedef和#define的区别 typedef int* pInt; , b = ; const pInt p1 = &a; //p1是常量指针 pInt const p2 = &a ...