Reputation: 89
Currently i have a virtualenv created with the virtualenvwrapper. In that virtualenv i installed the cx_Oracle extension with pip install cx_Oracle.
I have a python script using several commands from cx_Oracle like connect and such.
When running my script thought the activated env (python script.py) it works fine and produces no errors.
But when i try to run the same script in PyCharm 4 it does not work. I have the virtualenv as intrepeter selected. When running the script i get an error as follows:
/Users/pgerrits/.virtualenvs/siebelaudit/bin/python3.4 -u /Applications/PyCharm.app/Contents/helpers/pydev/pydev_run_in_console.py 64420 64421 /Users/pgerrits/PycharmProjects/SiebelAudit/Audit/Siebel Audit/scratchpad.py
Running /Users/pgerrits/PycharmProjects/SiebelAudit/Audit/Siebel Audit/scratchpad.py
PyDev console: starting.
ImportError: dlopen(/Users/pgerrits/.virtualenvs/siebelaudit/lib/python3.4/site-packages/cx_Oracle.so, 2): Library not loaded: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1
Referenced from: /Users/pgerrits/.virtualenvs/siebelaudit/lib/python3.4/site-packages/cx_Oracle.so
Reason: image not found
When running the same script with the same command in the terminal with the env activated, i get no error.
I already tried the following: - Added ENV variables for oracle_home, etc using a script - added env variables using the pycharm env variables option
It is really annoying that i have to switch to my mac terminal for running and debugging. Has anyone a clue what could be the issue here?
Upvotes: 7
Views: 3839
Reputation: 1
import os
import platform
if platform.system() == 'Darwin':
os.environ["ORACLE_HOME"] = '/opt/oracle/instantclient_11_2'
os.environ["DYLD_LIBRARY_PATH"] = '/opt/oracle/instantclient_11_2'
os.environ["LD_LIBRARY_PATH"] = '/opt/oracle/instantclient_11_2'
Upvotes: 0
Reputation: 19368
This is a known issue of PyCharm. The only way is to create virtualenv using PyCharm. If you create with virtualenvwrpper, there's a chance that PyCharm won't recognize it.
Upvotes: 1
Reputation: 16440
I had to set the environment variables for ORACLE_HOME
DYLD_LIBRARY_PATH
and LD_LIBRARY_PATH
and restart PyCharm to get cx_Oracle to work.
Upvotes: 6