Python cx_Oracle error
<p>I try to run a python scrapy crawler with crontab on Ubuntu, but i got this error message:</p>

<pre><code>Traceback (most recent call last):
  File "/usr/bin/scrapy", line 9, in &lt;module&gt;
    load_entry_point('Scrapy==1.0.3', 'console_scripts', 'scrapy')()
  File "/usr/lib/python2.7/dist-packages/scrapy/cmdline.py", line 142, in execu$
    cmd.crawler_process = CrawlerProcess(settings)
  File "/usr/lib/python2.7/dist-packages/scrapy/crawler.py", line 209, in __ini$
    super(CrawlerProcess, self).__init__(settings)
  File "/usr/lib/python2.7/dist-packages/scrapy/crawler.py", line 115, in __ini$
    self.spider_loader = _get_spider_loader(settings)
  File "/usr/lib/python2.7/dist-packages/scrapy/crawler.py", line 296, in _get_$
    return loader_cls.from_settings(settings.frozencopy())
  File "/usr/lib/python2.7/dist-packages/scrapy/spiderloader.py", line 30, in f$
    return cls(settings)
  File "/usr/lib/python2.7/dist-packages/scrapy/spiderloader.py", line 21, in _$
    for module in walk_modules(name):
  File "/usr/lib/python2.7/dist-packages/scrapy/utils/misc.py", line 71, in wal$
    submod = import_module(fullpath)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/kebodev/scrapy/qgtest2/qgtest2/spiders/jsonspider.py", line 5, in &lt;module&gt;
    import cx_Oracle
ImportError: libclntsh.so.11.1: cannot open shared object file: No such file or directory
</code></pre>

<p>I edit my ~/.bashrc with root user and added this lines:</p>

<pre><code>export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export ORACLE_SID=XE
export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
export ORACLE_BASE=/u01/app/oracle
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH
</code></pre>

<p>My libclntsh.so.11.1 is located here: <code>/u01/app/oracle/product/11.2.0/xe/lib</code></p>

<p>If I try to run my python scrapy crawler from terminal, it's running, and it's also works if I try to import cx_Oracle in python shell, but with crontab it's not ok..</p>

<p>This is how my cron job line looks like: </p>

<pre><code>* * * * * root /etc/listarunner.sh &gt;&gt; /home/kebodev/scrapy/qgtest2/etcronlog1.log 2&gt;&amp;1
</code></pre>

<p>And this is my <code>listarunner.sh</code> file:</p>

<pre><code>#!/bin/bash
cd /home/kebodev/scrapy/qgtest2
PATH=$PATH:/usr/local/bin
export PATH
scrapy crawl jsontst
</code></pre>

<p>Can anybody help me?</p>

<p>Thank you!  </p>

<p>I have a few options you can try:</p>

<p>1) Set the environment variables in listarunner.sh instead of ~/.bashrc</p>

<p>2) Use a file in /etc/ld.so.conf.d to make the setting of LD_LIBRARY_PATH unnecessary</p>

<p>3) Rebuild cx_Oracle, first setting the environment variable FORCE_RPATH to any value before building.</p>

<p>Hopefully one of those will help you out!</p>

python ubuntu scrapy crontab cx-oracle