PostgreSQL13 安装 psycopg2

一、先安装依赖包

1、安装postgreSQL13

PostgreSQL13 安装 psycopg2

 

 安装步骤

rpm -ivh postgresql13-libs-13.4-1PGDG.rhel7.x86_64.rpm

rpm -ivh postgresql13-13.4-1PGDG.rhel7.x86_64.rpm

rpm -ivh postgresql13-server-13.4-1PGDG.rhel7.x86_64.rpm

rpm -ivh postgresql13-contrib-13.4-1PGDG.rhel7.x86_64.rpm

2、安装postgresql13-devel依赖包

libicu-devel

llvm-toolset-7-clang

llvm5.0-devel

PostgreSQL13 安装 psycopg2

yum -y install libicu-devel

llvm5.0-devel(没有包)

llvm-toolset-7-clang(没有包)

强制安装postgresql13-devel

PostgreSQL13 安装 psycopg2

二、安装psycopg2

1、直接安装rpm包

PostgreSQL13 安装 psycopg2

 

安装后只有python2.7能用

2、使用tar包安装

1)先安装python3.7

安装编译相关工具包

yum -y groupinstall "Development tools"

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel yum install libffi-devel -y

 下载python3.7

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz

tar -xvJf Python-3.7.0.tar.xz

编译安装

mkdir /usr/local/python3 #创建编译安装目录

cd Python-3.7.0

./configure --prefix=/usr/local/python3

make && make install

创建软连接

ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3

ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3

2)下载适配 python3.7 的tar包

tar -vzxf psycopg2-2.9.1.tar.gz

cd psycopg2-2.9.1/

PostgreSQL13 安装 psycopg2

 

安装前,需要配置 pg_config:

vim setup.cfg

配置 pg_config

PostgreSQL13 安装 psycopg2

 

3)setup.py安装

python3 setup.py build

python3 setup.py install

PostgreSQL13 安装 psycopg2

 

三、验证

import psycopg2

PostgreSQL13 安装 psycopg2

 

上一篇:[转]nginx rewirte 规则出现emerg错误解决


下一篇:centos7基本环境安装