gpt4 book ai didi

Python cx_Oracle 错误

转载 作者:行者123 更新时间:2023-12-04 19:15:21 29 4
gpt4 key购买 nike

我尝试在 Ubuntu 上使用 crontab 运行 python scrapy 爬虫,但收到以下错误消息:

Traceback (most recent call last):
File "/usr/bin/scrapy", line 9, in <module>
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 <module>
import cx_Oracle
ImportError: libclntsh.so.11.1: cannot open shared object file: No such file or directory

我用 root 用户编辑我的 ~/.bashrc 并添加了以下行:
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

我的 libclntsh.so.11.1 位于: /u01/app/oracle/product/11.2.0/xe/lib
如果我尝试从终端运行我的 python scrapy 爬虫,它正在运行,如果我尝试在 python shell 中导入 cx_Oracle,它也可以工作,但是使用 crontab 就不行了。

这就是我的 cron 工作线的样子:
* * * * * root /etc/listarunner.sh >> /home/kebodev/scrapy/qgtest2/etcronlog1.log 2>&1

这是我的 listarunner.sh文件:
#!/bin/bash
cd /home/kebodev/scrapy/qgtest2
PATH=$PATH:/usr/local/bin
export PATH
scrapy crawl jsontst

有谁能够帮我?

谢谢!

最佳答案

我有几个选项你可以试试:

1) 在 listarunner.sh 而不是 ~/.bashrc 中设置环境变量

2) 使用/etc/ld.so.conf.d 中的文件,使 LD_LIBRARY_PATH 的设置变得不必要

3) 重建cx_Oracle,先将环境变量FORCE_RPATH设置为任意值再构建。

希望其中之一可以帮助您!

关于Python cx_Oracle 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39921696/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com