CentOS5.5上安装psycopg2
2016-02-04 09:28
399 查看
CentOS5.5上安装psycopg2
准备
接上一篇文章[CentOS5.5上安装Python2.7及ez_setup和pip包],先安装好python2.7和pip。安装postgresql开发包
CentOS5.5默认的postgresql版本比较低,需要安装高版本的postgresql库。访问 http://yum.postgresql.org/rpmchart.php, 下载postgresql 9.1的库。
下面几个链接是我下载的版本
- http://yum.postgresql.org/9.1/redhat/rhel-5-x86_64/postgresql91-9.1.19-1PGDG.rhel5.x86_64.rpm
- http://yum.postgresql.org/9.1/redhat/rhel-5-x86_64/postgresql91-libs-9.1.19-1PGDG.rhel5.x86_64.rpm
- http://yum.postgresql.org/9.1/redhat/rhel-5-x86_64/postgresql91-devel-9.1.19-1PGDG.rhel5.x86_64.rpm
[code]$ sudo rpm -ivh postgresql91-libs-9.1.19-1PGDG.rhel5.x86_64.rpm $ sudo rpm -ivh postgresql91-9.1.19-1PGDG.rhel5.x86_64.rpm $ sudo rpm -ivh postgresql91-devel-9.1.19-1PGDG.rhel5.x86_64.rpm
安装psycopg2
此时如果使用下面的命令安装psycopg2,仍然会有编译错误。[code]$ sudo /opt/python27/bin/pip install
所以,退而求其次,只能安装一个老版本的psycopg2。访问 http://initd.org/psycopg/tarballs/ 找到一个老版本,这里使用2.0.1版本,使用下面命令安装。
[code]$ sudo /opt/python27/bin/pip install http://initd.org/psycopg/tarballs/PSYCOPG-2-0/psycopg2-2.0.1.tar.gz[/code]测试
[code]import psycopg2 conn = psycopg2.connect(host="...", database="...", user="...", password="...") cursor = conn.cursor () cursor.execute ("select * from ...") row = cursor.fetchone () print row cursor.close () conn.close ()
转载请以链接形式标明本文地址
本文地址:/article/3647402.html
相关文章推荐
- 树莓派 CentOS 系统下载地址
- linux Socket 编程
- Linux 容器技术史话:从 chroot 到未来
- centos vmware centos6.6 64位 kvm虚拟化安装配置 第四十二节课
- Linux启动流程
- CentOS6.5下修改MySQL编码方法
- 【Linux】SVN的安装和配置
- 十指相扣:陪binderIPC度过的漫长岁月(3)
- Linux Crontab定时任务笔记
- centos7-nagiospnp-4.08配置
- Linux安装openssl详细步骤
- Linux下查看文件和文件夹大小
- linux 将光盘package作为yum源的方法及实践
- linux route路由
- Centos6.5x64 安装scrapy1.0.4成功
- linux下开启mysql慢查询,分析查询语句
- 服务器搭建局域网访问
- vim与复制,删除,粘贴,块操作以及快速替换功能
- Linux部分命令解释(命令缩写代表什么意思)
- linux实战案例-2