Domanda

I am having issiues installing cx_oracle. I have installed oracle instantclient and cx_oracle oracle packages ones installed i am getting this error while importing cx_oracle. i am running ubuntu 11.10 as host.

import cx_Oracle
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: /usr/lib/python2.7/dist-packages/cx_Oracle.so: undefined symbol:PyUnicodeUCS2_AsEncodedString

any one have any idea how to resolve this issue

cheers

È stato utile?

Soluzione

Most probably your Python install uses another unicode format (ucs4) and cx_oracle was compiled with ucs2.

You can install cx_Oracle 5.0.4 with the unicode flag. That worked for me but there is some bug: strange Oracle error: "invalid format text"

Or compile the latest cx_oracle yourself. http://mrpolo.com.ve/?p=178 (its some language i don't know but it helped)

Altri suggerimenti

I addition to @froZieglers answer. When I came along the cx_Oracle page there was no "...Unicode..."-Variant to download anymore. Luckily compiling it myself from source was not a big a hassle then I expected.

Here a summary about what I did (Ubuntu 12.04 LTS, 64bit):

  • install the proper Oracle XE client rpm with alien (11g, 64bit, etc...)
    • it installs th /u01/..., I had to adjust .profile too, of course.
  • download cx_Oracle source-tar, untar, cd into
    • I did the ln -s command on the so-lib on Oracle, as said in BUILD text file
  • Install Python headers with sudo aptitude install python-dev
  • Compile with python setup.py build
  • Install with sudo python setup.by install
    • First try failed with distutils.errors.DistutilsSetupError: cannot locate an Oracle software installation
    • patched setup.py with setting userOracleHome = "/u01/app/oracle/product/11.2.0/xe" after os.getenv("ORACLE_HOME")
    • sudo python setup.by install then worked
  • Check with python -c 'import cx_Oracle' succeeded.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top