Unable to get cx_Oracle to work with Python version 2.7 / mac os 10.7.2 (Lion) - missing_OCIAttrGet

Unable to get cx_Oracle to work with Python version 2.7 / mac os 10.7.2 (Lion)

One more thing: I installed oracle 32 bit, not sure if this was correct.

Traceback (most recent call last): File "reader.py", line 9, in <module> import cx_Oracle File "build/bdist.macosx-10.7-intel/egg/cx_Oracle.py", line 7, in <module> File "build/bdist.macosx-10.7-intel/egg/cx_Oracle.py", line 6, in __bootstrap__ ImportError: dlopen(/Users/me/.python-eggs/cx_Oracle-5.1.1-py2.7-macosx-10.7-intel.egg-tmp/cx_Oracle.so, 2): Symbol not found: _OCIAttrGet Referenced from: /Users/me/.python-eggs/cx_Oracle-5.1.1-py2.7-macosx-10.7-intel.egg-tmp/cx_Oracle.so Expected in: flat namespace in /Users/me/.python-eggs/cx_Oracle-5.1.1-py2.7-macosx-10.7-intel.egg-tmp/cx_Oracle.so 

The key problem does not seem to be able to find _OCIAttGet , and I think it means that it cannot find the lib file or something like that.

Found on the Internet, someone is talking about DYLD_LIBRARY_PATH , but mine is installed, however he mentioned it in the cxoracle.cfg file that I cannot find, is this my problem?

EDIT

After trying to run it using 32-bit python mode, I see another error.

  Traceback (most recent call last): File "reader.py", line 9, in <module> import cx_Oracle File "build/bdist.macosx-10.7-intel/egg/cx_Oracle.py", line 7, in <module> File "build/bdist.macosx-10.7-intel/egg/cx_Oracle.py", line 3, in __bootstrap__ ImportError: No module named pkg_resources 
  • I was unable to run 64-bit versions of oracle to work on my computer, continued to receive segmentation errors when I started sqlplus, so therefore I use 32.

SECOND EDIT

Actually, no matter what I install, this is not the correct version .. 32-bit version

  ld: warning: ignoring file /opt/oracle/instantclient10_2/libclntsh.dylib, file was built for unsupported file format which is not the architecture being linked (i386) 

64-bit version:

  ld: warning: ignoring file /opt/oracle/instantclient10_2/libclntsh.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64) 

I am going to try 11g, but this only has a 64bit version.

+6
source share
5 answers

If you use the supplied Apple Python 2.7, it will prefer to work in 64-bit mode, and this will be a problem if you installed the 32-bit Oracle libraries. You can try to get this Python to work in 32-bit mode by running it like this:

 arch -i386 python2.7 

If you try to always run python through /usr/bin/python , you can also use any of the methods described on the Apple man page for Python, that is, set the environment variable VERSIONER_PYTHON_PREFER_32_BIT or set a constant default value through defaults .

+2
source

In compiling cx_Oracle so that it works on OS X , you need to configure several settings. Important bits are:

  • Create virtualenv with a python interpreter split only into 32-bit. In the virtualenv bin directory ( $WORKON_HOME/*name_of_virtualenv*/bin ):

     % mv python python.fat % lipo python.fat -remove x86_64 -output python 
  • Although Python is now thin, its configuration is wrong, we need to make things use an obscure environment variable that distutils will take:

     ARCHFLAGS="-arch i386" pip install cx_Oracle 
+6
source

Not sure if you still have problems with this, but here's how I earned it.

I followed the instructions given here (using 32-bit downloads from Oracle): http://www.xairon.net/2011/05/guide-installing-cx_oracle-on-mac-os-x/

Then I had the same error you indicated:

ImportError: dlopen (/Library/Python/2.7/site-packages/cx_Oracle.so, 2): Symbol not found: _OCIAttrGet Link: /Library/Python/2.7/site-packages/cx_Oracle.so Expected in: flat namespace in / Library / Python / 2.7 / site-packages / cx_Oracle.so

The problem was with the Apple Python distribution, which runs in 64-bit mode by default.

Once I got Apple to ship Python to use 32-bit (from the Ned recommendation), it will work!

For this:

$ export VERSIONER_PYTHON_PREFER_32_BIT = Yes

To make it permanent:

$ defaults write com.apple.versioner.python I prefer -32-bit-dub yes

+2
source

Steps to install oracle client on mac ox 10.8.5 to connect oracle from python. (There is an error due to which 64 bit does not work for mac ox 10.8.5)

  • Go to http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
  • Download file instantclient-basic-macos.x32-11.2.0.3.0.zip
  • Download file instantclient-sdk-macos.x32-11.2.0.3.0.zip
  • Create a new folder under / Users / <your username> / ora_32 (you can name what you want)
  • Move the zip files instantclient-sdk-macos.x32-11.2.0.3.0.zip and instantclient-basic-macos.x32-11.2.0.3.0.zip to / Users / <your username> / ora_32. Team below

     mv insta*32* /Users/< your username>/ora_32/ 
  • Unzip instantclient-basic-macos.x32-11.2.0.3.0.zip and instantclient-sdk-macos.x32-11.2.0.3.0.zip The command below

     cd /Users/< your username>/ora_32/ unzip instantclient-basic-macos.x32-11.2.0.3.0.zip unzip instantclient-sdk-macos.x32-11.2.0.3.0.zip 
  • it will create an instantclient_11_2 folder under / Users // ora _32 /
  • cd to / Users / <your username> / ora_32 / instantclient_11_2 and create the symbolic link below that will be used when installing cx_Oracle. (Mentioned below)

     ln -s libclntsh.dylib.11.1 libclntsh.dylib ln -s libocci.dylib.11.1 libocci.dylib 
  • Export environment variables for the current session or you can add them to your bash profile to call a new terminal every time you open it.

     export ORACLE_HOME=/Users/<your username>/ora_32/instantclient_11_2 export LD_LIBRARY_PATH=$ORACLE_HOME export DYLD_LIBRARY_PATH=$ORACLE_HOME export VERSIONER_PYTHON_PREFER_32_BIT=yes export PATH=$PATH:/Users/<your username>/ora_32/instantclient_11_2 
  • Download cx_Oracle (version source code only) from http://cx-oracle.sourceforge.net
  • Untie the cx_Oracle tar file and create the cx_Oracle-5.1.2 cd folder in this cx_Oracle-5.1.2 folder
  • Run the command below to install cx_Oracle and then

      sudo easy_install cx_Oracle 
  • You can check by going to the python prompt and typing import cx_Oracle
+2
source

I had the same problem. I am using Mac OS X 10.8.3.

After 4 hours of trying various solutions, I finally realized that this was the result of installing the 32-bit version of Oracle InstantClient, which contradicted the 64-bit version of python.

To solve: I uninstalled python (and some dependencies) and then reinstalled the universal version. I followed the directions in this post to remove x86_64 from the python binary in my virtualenv. This allowed 32-bit Oracle InstantClient to work with 32-bit python binary.

I hesitate to use the 64-bit Oracle InstantClient due to some other messages that I saw while investigating this problem.

0
source

Source: https://habr.com/ru/post/901724/


All Articles