It’s not obvious to set it right, so I’m putting some notes here:
Installation is described here.
- ORACLE_HOME is needed just for installation
- If you add client library path to
ldconfig, you don’t need to export modified LD_LIBRARY_PATH
- when you install Oracle client library and set environment, you can install cx_oracle also via
pip install cx_Oracle
The crucial step not mentioned in the installation guide is to set NLS_LANG environment variable – this should be in the environment of your python program using cx_oracle. So for instance for Flask+SQLAlchemy you can have:
Without this variable oracle client is using 7bits ASCII! So any unicode character will raise “UnicodeEncodeError: ‘ascii’ codec can’t encode character” error.