Dependências de instalação ao tentar instalar o cx_oracle

1

Estou tentando instalar o cx_Oracle para usar em um script python em um ubuntu vm. Primeiramente, eu segui os primeiros passos listados em site . Eu fiz originalmente alguns erros de substituição que eu me livrei fazendo

sudo dpkg -i --force-overwrite (.deb file)

Eu tive que substituir duas vezes, uma vez ao instalar o arquivo cx_oracle .deb e depois a segunda vez ao instalar o arquivo instantclient12.1-basic .deb.

Depois tentei importar o cx_Oracle para o python e obtive um ImportError. Eu tentei instalar via pip e recebi o seguinte erro:

sudo -H pip install cx_oracle
Collecting cx_oracle
  Using cached cx_Oracle-5.2.1.tar.gz
Building wheels for collected packages: cx-oracle
  Running setup.py bdist_wheel for cx-oracle ... error
  Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-12y5OC/cx-oracle/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpgkWhJhpip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_ext
  building 'cx_Oracle' extension
  creating build
  creating build/temp.linux-x86_64-2.7-12c
  x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/oracle/12.1/client64 -I/usr/include/python2.7 -c cx_Oracle.c -o build/temp.linux-x86_64-2.7-12c/cx_Oracle.o -DBUILD_VERSION=5.2.1
  cx_Oracle.c:6:20: fatal error: Python.h: No such file or directory
   #include <Python.h>
                      ^
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for cx-oracle
  Running setup.py clean for cx-oracle
Failed to build cx-oracle
Installing collected packages: cx-oracle
  Running setup.py install for cx-oracle ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-12y5OC/cx-oracle/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-bPwpiX-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'cx_Oracle' extension
    creating build
    creating build/temp.linux-x86_64-2.7-12c
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/oracle/12.1/client64 -I/usr/include/python2.7 -c cx_Oracle.c -o build/temp.linux-x86_64-2.7-12c/cx_Oracle.o -DBUILD_VERSION=5.2.1
    cx_Oracle.c:6:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-12y5OC/cx-oracle/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-bPwpiX-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-12y5OC/cx-oracle/

Analisei o erro e encontrei alguns links do askubuntu, como isso que recomenda instalar o python-dev

Aqui está o resultado de tentar instalá-lo:

sudo apt-get install python-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 python-dev : Depends: libpython-dev (= 2.7.5-5ubuntu3) but it is not going to be installed
              Depends: python2.7-dev (>= 2.7.5-1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Eu tentei seguir os passos no geral dependências não atendidas postam e ainda não têm sorte. Eu também tentei instalar os dois pacotes que precisava e só se deparou com ainda mais dependências.

sudo apt-get install libpython-dev python2.7-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libpython-dev : Depends: libpython2.7-dev (>= 2.7.5-1~) but it is not going to be installed
 python2.7-dev : Depends: libpython2.7-dev (= 2.7.6-8ubuntu0.3) but it is not going to be installed
                 Depends: libexpat1-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Aqui está minha lista de fontes:

#This file is generated by Chef.  Do not edit!
deb  http://archive.ubuntu.com/ubuntu trusty main universe
deb  http://archive.ubuntu.com/ubuntu trusty-updates main universe
deb  http://archive.ubuntu.com/ubuntu trusty-security main universe

Estou perdendo alguma fonte ou há algo mais que eu deveria estar fazendo para instalar o cx_Oracle?

EDITAR: Eu já tenho o oracle db client instalado e então eu já tinha o seguinte rpms instalado

oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm

oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm

oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm

Eu então instalei:

cx_Oracle-5.2.1-11g-py27-1.x86_64.rpm

    
por bbakp3 22.02.2017 / 19:35

1 resposta

0

O cx_Oracle vem com um arquivo .so de extensão que não parece ser compatível com a distribuição padrão da roda bdist. O bdist inclui apenas arquivos Python padrão, então você deve incluir isso explicitamente como parte do arquivo de dados em setup.py

    
por ravi p 28.05.2018 / 20:45