在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 ...
随机推荐
- Android开发之利用ViewPager实现页面的切换(仿微信、QQ)
这里利用ViewPager实现页面的滑动,下面直接上代码: 1.首先写一个Activity,然后将要滑动的Fragment镶嵌到写好的Activity中. Activity的布局文件:activity ...
- kafka配置简要描述
配置文件在config/server.properties 下面的一些配置可能是你需要进行修改的. 这里为官方提供配置文件解释:https://kafka.apache.org/08/configur ...
- websocket activemq
websocket:应用与服务端保持长连接 不停通信 activemq:偶发通信 心跳机制
- Python之路(第十四篇)os模块
一.os模块 1.os.getcwd() 获取当前工作目录(当前工作目录默认都是当前文件所在的文件夹) import os print(os.getcwd()) 2.os.chdir(path) 改变 ...
- Jquery中的$.cookie()方法
jquery.cookie中的操作: jquery.cookie.js是一个基于jquery的插件,点击下载! 创建一个会话cookie: $.cookie(‘cookieName’,'cookieV ...
- Shortest Unsorted Continuous Subarray LT581
Given an integer array, you need to find one continuous subarray that if you only sort this subarray ...
- Windows使用SSH Secure Shell实现免密码登录CentOS
笔记来自:http://blog.csdn.net/jiangshouzhuang/article/details/50683049 1.在Windows上生成密钥找到Secure Shell Cli ...
- PHP删除空格函数
删除空格或其他字符的相关函数 ltrim函数 描述:实现删除字符串开始位置的空格或其他字符 语法:string ltrim(string $str [,string $charlist]) 说明:ch ...
- 使用delphi 10.2 开发linux 上的webservice
前几天做了linux下apache的开发,今天做一个linux 下的webservice ,以供客户端调用. 闲话少说,直接干. 新建一个工程.选other...,选择如图. 继续输入服务名 然后就生 ...
- 网络编程之IO模型
IO模型的分类 blocking IO:阻塞IO nonblocking IO:非阻塞IO IO multiplexing:IO多路复用 signal driven IO:异步IO 通常情况下IO默认 ...