# Python and cx_Oracle (or another solution)



## Telefunken (Jul 26, 2012)

Hello,

I've been trying to compile cx_Oracle to work with Python without success. I've installed the linux_base, linux-oracle-instantclient-basic, linux-oracle-instantclient-sdk and linux-oracle-instantclient-sqlplus ports and setup the ORACLE_HOME correctly. I've configured the linux_enable="YES" on rc.conf. When I try to compile cx_Oracle, I always got a:


```
# python setup.py build
libclntsh.so: could not read symbols: File in wrong format
error: command 'cc' failed with exit status 1
```

Thing is, I really need to access an Oracle database from Python, and I've read that I need to compile Python to run in linux compatible mode to install cx_Oracle, how do I do that? Plus, if one of you guys have a sucessful Python setup to access an Oracle 9i database (it doesn't need to be cx_Oracle, exactly) would you mind to share the steps to take?

Thanks in advance.


----------



## SirDice (Jul 26, 2012)

I've searched before, for the past few years many people have tried but nobody ever succeeded.

Thread 33291


----------



## Telefunken (Jul 27, 2012)

Thanks for the answer, SirDice. Did you manage to find any solution to access Oracle from Python? At the moment I'm calling some PHP code to access the database, it's just plain ugly and kills me inside.


----------



## firass (Aug 16, 2012)

Telefunken said:
			
		

> Thanks for the answer, SirDice. Did you manage to find any solution to access Oracle from Python? At the moment I'm calling some PHP code to access the database, it's just plain ugly and kills me inside.



Telefunken, we've been using FreeBSD/Python/cx_Oracle to connect to Oracle since 2008.

Looking at your error message:

```
# python setup.py build
libclntsh.so: could not read symbols: File in wrong format
error: command 'cc' failed with exit status 1
```

It may be that you're running 64-bit FreeBSD with the 32-bit Oracle. Is this correct?


----------



## ErikCederstrand (Jun 13, 2018)

There's another thread at https://forums.freebsd.org/threads/oracle-python-cx_oracle-for-amd64.33291/#post-390798 with useful information regarding cx_Oracle.


----------

