Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
install cx_oracle
in progress (#1046): re-focus this page on deployment of python on linux, esp. suse; perhaps move to PythonDeployment?. for developer set-up, see WritingQualityCode
virtualenv is a tool to create isolated Python environments:
The basic problem being addressed is one of dependencies and versions, and indirectly permissions. Imagine you have an application that needs version 1 of LibFoo , but another application requires version 2. How can you use both these applications? Or what if you want to install an application and leave it be ? If an application works, any change in its libraries or the versions of those libraries can break the application. ... In all these cases, virtualenv can help you.
Machine Set-Up
If your development machine runs ubuntu (or debian) linux, install with apt-get:
$ sudo apt-get install python-virtualenv
SuSE Enterprise is trickier. Even the SDK doesn't seem to have a virtualenv package. So we can install from source, starting at the python package index, then to "get pip" etc.:
> md5sum
> sudo python
dconnolly's password:
Extracting in /tmp/tmp5lAMQe
> wget
> tar zxf virtualenv-1.6.4.tar.gz
~/virtualenv-1.6.4> sudo python install
Finished processing dependencies for virtualenv==1.6.4
Mixing a repository from opensuse with SLES seems iffy, but it seems to have worked in the past:
> sudo zypper ar -f
> sudo zypper install python-virtualenv
Check for key fingerprint 172CCD6B0CF49B7388F1C61127163A4EEDF0D733.
Set-Up for building python extensions
Some python packages involve not just python code but a compiled extension. To compile the extension, the machine needs Python.h and the rest of the python development files.
In SuSE, these are in the python-devel package, which is on the SDK DVD. Ask InformationResources to install the package.
Python and XML
The lxml package provides a great API for working with XML in python, but it's not pure python. Before you can easy_install lxml, you'll need libxml2 and libxslt. On SuSE:
$ sudo zypper install libxml2-devel libxslt-devel
Python and Oracle
Notes on Oracle Access module
cx_Oracle is a Python extension module that allows access to Oracle databases and conforms to the Python database API specification.
The Build Hints explain how it interfaces with drivers from Oracle. The files for our 64 bit intel architecture are in Oracle instant client downloads for x86-64:
~/Downloads$ md5sum instantclient-*
Once those are unzipped under /usr/local, the next step is:
$ export ORACLE_HOME=/usr/local/instantclient_11_2/
$ sudo ln -s
$ sudo ln -s
On my Ubuntu box, I ran into ImportError: cannot open shared object file; the solution came from a December 28, 2009 post on Django and Oracle support:
$ sudo apt-get install -y libaio1
Then it's pretty straightforward:
$ pip install cx_Oracle
Downloading/unpacking cx-Oracle
Running egg_info for package cx-Oracle
Installing collected packages: cx-Oracle
Running install for cx-Oracle
building 'cx_Oracle' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/local/instantclient_11_2/sdk/include -I/usr/include/python2.6 -c cx_Oracle.c -o build/temp.linux-x86_64-2.6-11g/cx_Oracle.o -DBUILD_VERSION=5.0.4
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions build/temp.linux-x86_64-2.6-11g/cx_Oracle.o -L/usr/local/instantclient_11_2/lib -L/usr/local/instantclient_11_2/ -lclntsh -o build/lib.linux-x86_64-2.6-11g/
Successfully installed cx-Oracle
Cleaning up...
Download in other formats:
Plain Text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.