av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

安裝python依賴包psycopg2來(lái)調(diào)用postgresql的操作

瀏覽:2日期:2022-06-30 16:23:50
1、先安裝psycopg2的依賴組件

本案例的操作系統(tǒng)為linux red hat

在安裝python依賴包psycopg之前,你必須需要先安裝postgresql數(shù)據(jù)庫(kù)的相關(guān)組件:

postgresql-devel,postgresql,postgresql-libs這三個(gè)組件比較重要。另外,可選組件:postgresql-server

安裝上述組件之前,可以用命令來(lái)查看你的系統(tǒng)現(xiàn)在是否已經(jīng)安裝了相關(guān)組件:

[root@dthost27 ~]# rpm -qa | grep PostgreSQL

如果都沒有安裝,則可執(zhí)行命令如下:

[root@dthost27 ~]# yum install postgresql-devel

(安裝過(guò)程中會(huì)順帶安裝上postgresql和postgresql-libs組件)

2、安裝psycopg2依賴包

保證依賴組件存在后,就可以使用pip命令安裝了:

[root@dthost27 ~]# pip install psycopg2-binary

注:這里安裝的是binary格式的psycopg2依賴包,其實(shí)安裝psycopg2也可以,但是有時(shí)候執(zhí)行pip install psycopg2會(huì)報(bào)錯(cuò),而安裝psycopg2-binary(編譯后)則不會(huì)

啟動(dòng)python測(cè)試

import psycopg2

補(bǔ)充:安裝psycopg2報(bào)錯(cuò)_解決方案

報(bào)錯(cuò)信息

(python3-virtualenv) [root@vl-bg-anaylsis02 extract_log]# pip3 install psycopg2Collecting psycopg2 Using cached psycopg2-2.8.4.tar.gz (377 kB) ERROR: Command errored out with exit status 1: command: /disk2/extract_log/python3-virtualenv/bin/python3 -c ’import sys, setuptools, tokenize; sys.argv[0] = ’'’'’/tmp/pip-install-2d9wyu3k/psycopg2/setup.py’'’'’; __file__=’'’'’/tmp/pip-install-2d9wyu3k/psycopg2/setup.py’'’'’;f=getattr(tokenize, ’'’'’open’'’'’, open)(__file__);code=f.read().replace(’'’'’rn’'’'’, ’'’'’n’'’'’);f.close();exec(compile(code, __file__, ’'’'’exec’'’'’))’ egg_info --egg-base /tmp/pip-install-2d9wyu3k/psycopg2/pip-egg-info cwd: /tmp/pip-install-2d9wyu3k/psycopg2/ Complete output (23 lines): running egg_info creating /tmp/pip-install-2d9wyu3k/psycopg2/pip-egg-info/psycopg2.egg-info writing /tmp/pip-install-2d9wyu3k/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO writing dependency_links to /tmp/pip-install-2d9wyu3k/psycopg2/pip-egg-info/psycopg2.egg-info/dependency_links.txt writing top-level names to /tmp/pip-install-2d9wyu3k/psycopg2/pip-egg-info/psycopg2.egg-info/top_level.txt writing manifest file ’/tmp/pip-install-2d9wyu3k/psycopg2/pip-egg-info/psycopg2.egg-info/SOURCES.txt’ Error: pg_config executable not found. pg_config is required to build psycopg2 from source. Please add the directory containing pg_config to the $PATH or specify the full executable path with the option: python setup.py build_ext --pg-config /path/to/pg_config build ... or with the pg_config option in ’setup.cfg’. If you prefer to avoid building psycopg2 from source, please install the PyPI ’psycopg2-binary’ package instead. For further information please check the ’doc/src/install.rst’ file (also at <http://initd.org/psycopg/docs/install.html>). ----------------------------------------ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.解決方案 For ubuntu

sudo apt-get install libpq-dev python3-dev解決方案 For Fedora/Centos

yum install -y postgresql10yum install postgresql-libs python3-devel postgresql-develyum install gcc

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教。

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 成人精品国产一区二区4080 | 6080亚洲精品一区二区 | 亚洲成人精选 | 久夜精品| 午夜视频免费网站 | 久久精品97 | 国产精品视频一区二区三 | a在线视频| 欧美日本一区 | 一区二区三区四区av | 在线欧美小视频 | 精品国产一区二区三区在线观看 | 久久成人国产精品 | 啪一啪 | 亚洲视频一区二区三区四区 | 一本一道久久a久久精品综合蜜臀 | 韩国理论电影在线 | 日韩精品在线观看视频 | 福利一区视频 | 亚洲精品一区中文字幕乱码 | 久久久精品视频免费看 | 深夜爽视频 | 狠狠干天天干 | 天堂网中文 | www.4567| 狠狠插天天干 | 日本精品一区二区 | 自拍偷拍3p | 中文字幕综合在线 | 国产乱人伦精品一区二区 | 成人乱人乱一区二区三区软件 | 天天射天天干 | 91视频大全 | 欧美国产视频 | 亚洲精品第一页 | 日本在线视频一区二区 | 一级在线观看 | 日韩欧美国产精品一区 | 黄色一级片视频 | 97精品超碰一区二区三区 | 91高清免费观看 |