dfdfdfgdfd

domingo, 1 de abril de 2012

Instalar psycopg no Fedora 17


Abaixo segue simples passos para instalação do psycopg  no Fedora 17.

O psycopg é um driver Python para PostgreSQL muito popular que implementa  a Python Database API Specification v2.0 alem de ser compatível com Django.

1. Download do source em http://initd.org/psycopg/download/
2. $ tar -zxvf psycopg2-2.5.3.tar.gz
3. $ python setupe.py install

Pronto, este é o caminho feliz! Mas sempre tem o proem, então segue abaixo lista de erros e soluções que podem acontecer durante a instalação em distribuições linux derivadas do Red Hat.

Erro 1: "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'."

Solução: Altere o arquivo de configurações setup.cfg apontando para sua instalação do PostgreSql, conforme exemplo a seguir:

Atual versão 2.5.3
  • pg_config=/opt/PostgreSQL/9.2/bin/pg_config
  • mx_include_dirs=/opt/PostgreSQL/9.2/include/postgresql:/opt/PostgreSQL/9.2/include/postgresql/server
Versão antiga  2.4.5
  • include_dirs=/opt/PostgreSQL/9.2/include/postgresql:/opt/PostgreSQL/9.2/include/postgresql/server 
  • library_dirs=/usr/lib64
  • libraries=/usr/lib
Erro 2: "fatal error: Python.h: No such file or directory"

Solução: $ yum install pyhon-devel

Erro 3: Os erros anteriores podem acontecer na instalação executando o comando "python setupe.py install", mas quando for preciso usar a lib pode aparecer o seguinte erro "ImportError: libpq.so.5: cannot open shared object file: No such file or directory"

Solução:  $ yum install postgresql-libs

Vlw!

Um comentário:

  1. Outra solução rápida:

    $ yum install python-devel
    $ yum install postgres-devel
    $ yum install postgresql-libs
    $ yum install glibc-devel
    $ cd ../psycopg2-2.4.5
    $ python setup.py install

    ResponderExcluir