2017-04-27 2 views
0

Ich habe ein Projekt in Python (unter Ubuntu 12.04) mit Cx_Oracle (in einem virtualenv). Wenn ich das Projekt ausführe, habe ich keine Probleme beim Importieren dieses Moduls. Jetzt möchte ich mein Projekt mit einem Supervisor steuern. Als ich das Projekt von Vorgesetzten, beginnend Abstürze und steigt diese Ausnahme zu starten:Probleme beim Importieren von cx_oracle

File "/home/vagrant/scrapy/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker 
    worker.init_process() 
    File "/home/vagrant/scrapy/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process 
    self.load_wsgi() 
    File "/home/vagrant/scrapy/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi 
    self.wsgi = self.app.wsgi() 
    File "/home/vagrant/scrapy/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 
    self.callable = self.load() 
    File "/home/vagrant/scrapy/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load 
    return self.load_wsgiapp() 
    File "/home/vagrant/scrapy/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp 
    return util.import_app(self.app_uri) 
    File "/home/vagrant/scrapy/local/lib/python2.7/site-packages/gunicorn/util.py", line 352, in import_app 
    __import__(module) 
    File "/vagrant/scrapy_server/flask_server/api.py", line 8, in <module> 
    from resources.routes import routes 
    File "/vagrant/scrapy_server/flask_server/resources/routes.py", line 1, in <module> 
    from server.server import ServerStart, ServerStatus, ServerStop 
    File "/vagrant/scrapy_server/flask_server/resources/server/server.py", line 8, in <module> 
    from core.pool import ThreadPool 
    File "/home/vagrant/scrapy/src/scrapy/scrapy_server/apps/core/pool.py", line 7, in <module> 
    from resources.resources import Resources 
    File "/vagrant/scrapy_server/flask_server/resources/resources.py", line 10, in <module> 
    from repository.HotTypes import HotTypes 
    File "/vagrant/scrapy_server/flask_server/resources/repository/HotTypes.py", line 1, in <module> 
    from db_pg import DBPostgres 
    File "/vagrant/scrapy_server/flask_server/resources/repository/db_pg.py", line 1, in <module> 
    from resources.db_pg import DBPostgres as DBpostgresResources 
    File "/vagrant/scrapy_server/flask_server/resources/db_pg.py", line 1, in <module> 
    from core.dbcore import DBpostgresCore 
    File "/home/vagrant/scrapy/src/scrapy/scrapy_server/apps/core/dbcore.py", line 3, in <module> 
    import cx_Oracle 
ImportError: libclntsh.so.11.1: cannot open shared object file: No such file or directory 

Ich folgte Anweisungen von this Seite und auch this other Ort. Aber ich konnte dieses Problem nicht beheben.

Der Supervisor conf Datei ist:

[program:api_server] 
command = /home/vagrant/scrapy/bin/gunicorn api:app 
directory = /home/vagrant/scrapy/src/scrapy/scrapy_server/flask_server/ 
environment = PATH="/home/vagrant/scrapy/bin/python", ORACLE_HOME="/usr/lib/oracle/12.1/client64", LD_LIBRARY_PATH="/usr/lib/oracle/12.1/client64/lib" 
user = vagrant 
autostart=true 
autorestart=true 
stderr_logfile=/var/log/api.err.log 
stdout_logfile=/var/log/api.out.log 
redirect_stderr = True 

Was soll ich hier fehlt? Wenn Sie weitere Informationen benötigen, lassen Sie es mich wissen und ich werde diese Frage aktualisieren.

Vielen Dank an alle

+0

Haben Sie alle erforderlichen Env-Variablen (wie $ ORACLE_HOME, ...) gesetzt? –

+0

ja, wie ich geschrieben habe, habe ich alle benötigten enviroments wie in einem Tutorial erklärt (Link ist oben). Das Projekt läuft perfekt, wenn ich es manuell starte – Sam

Antwort

1

Wenn Sie Oracle Instant Client verwenden, sollten Sie die Umgebungsvariable ORACLE_HOME nicht gesetzt. Das einzige, was Sie einstellen müssen, ist LD_LIBRARY_PATH, um den Speicherort von libclnts.so einzubeziehen.

Von Ihren Umgebungsvariablen verwenden Sie einen Oracle Instant Client mit Version 12.1, aber cx_Oracle selbst scheint mit 11.2 kompiliert zu sein. Das muss korrigiert werden. Sie müssen sicherstellen, dass cx_Oracle mit 12.1 kompiliert wurde, oder Sie müssen das neue cx_Oracle 6.0b1 verwenden, das automatisch zwischen verschiedenen Oracle-Client-Versionen wechselt.

+0

In der Tat war über die Verwendung von 12,1 statt 11,2 (Duh, ich habe es übersehen). Ich werde Oracle testen, ohne ORACLE_HOME wie vorgeschlagen einzustellen. Danke für Ihre Hilfe! – Sam

Verwandte Themen