Ich versuche, einen Python-App auf meinem Apache Amazon EC2-Server über WSGI zu laufen, und ich erhalte immer diese Fehlermeldung:Import: Kein Modul mit dem Namen cv2 - WSGI + Python + Apache
[Tue Aug 16 18:22:57 2016] [error] [client 72.219.147.5] mod_wsgi (pid=28751): Target WSGI script '/var/www/html/lumos/wsgi.py' cannot be loaded as Python module.
[Tue Aug 16 18:22:57 2016] [error] [client 72.219.147.5] mod_wsgi (pid=28751): Exception occurred processing WSGI script '/var/www/html/lumos/wsgi.py'.
[Tue Aug 16 18:22:57 2016] [error] [client 72.219.147.5] Traceback (most recent call last):
[Tue Aug 16 18:22:57 2016] [error] [client 72.219.147.5] File "/var/www/html/lumos/wsgi.py", line 11, in <module>
[Tue Aug 16 18:22:57 2016] [error] [client 72.219.147.5] import app
[Tue Aug 16 18:22:57 2016] [error] [client 72.219.147.5] File "/var/www/html/lumos/app.py", line 2, in <module>
[Tue Aug 16 18:22:57 2016] [error] [client 72.219.147.5] import main
[Tue Aug 16 18:22:57 2016] [error] [client 72.219.147.5] File "/var/www/html/lumos/main.py", line 1, in <module>
[Tue Aug 16 18:22:57 2016] [error] [client 72.219.147.5] import mod_one
[Tue Aug 16 18:22:57 2016] [error] [client 72.219.147.5] File "/var/www/html/lumos/mod_one.py", line 1, in <module>
[Tue Aug 16 18:22:57 2016] [error] [client 72.219.147.5] import cv2
[Tue Aug 16 18:22:57 2016] [error] [client 72.219.147.5] ImportError: No module named cv2
Hier die cv2.so Datei befindet (sudo find/-name "cv2.so"
):
/var/www/html/lumos/opencv/build/lib/cv2.so
/usr/local/lib/python2.7/dist-packages/cv2.so
Und ich die WSGI Python-Pfad festgelegt haben, wo die Datei gespeichert ist:
WSGIPythonPath /usr/local/lib/python2.7/site-packages/:/usr/local/lib/python2.7/dist-packages/
Ich weiß opencv richtig installiert ist, weil, wenn ich den folgenden Code, kein Fehler ist:
$ python
>>>import cv2 #no import error
>>>
Als ich mod_wsgi installiert, das verwendet wurde:
mod_wsgi-python26-3.2-6.11.amzn1.x86_64
Hier meine wsgi.py Datei ist
import os, sys
sys.path.insert(0, "/var/www/html/lumos")
import bottle
import app
application = bottle.default_app() #using bottle.py web-framework
Hier ist meine httpd.conf:
WSGISocketPrefix /var/run/wsgi
WSGIPythonPath /usr/local/lib/python2.7/site-packages/:/usr/local/lib/python2.7/dist-packages/
<VirtualHost *>
ServerName lumos.website.me
DocumentRoot /var/www/html/lumos
WSGIDaemonProcess lumos threads=5
WSGIScriptAlias//var/www/html/lumos/app.wsgi
<Directory "/var/www/html/lumos">
WSGIProcessGroup lumos
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Als ich python -V
laufen, bekomme ich Python 2.7.10.
Wie kann ich mod_wsgi Arbeit mit opencv machen? Jede Hilfe wird geschätzt.
Ich überprüfte erneut, und die Version von WSGI, die ich aus dem Fehlerprotokoll gefunden hatte, war tatsächlich veraltet (da ich im Fehlerprotokoll sehr weit nach oben scrollte, um diese Zeile zu finden). Ich hatte tatsächlich eine WSGI-Version von der Quelle für Python 2.7 zwischen damals und heute installiert, weshalb der Code am Laufen ist. –
Ich habe die WSGI-Versionszeile aus meiner Frage entfernt, da sie nicht korrekt ist. –
Sie sollten '' dist-packages'' und '' site-packages' 'nicht selbst zum Suchpfad des Python-Moduls hinzufügen. Wenn Sie das tun, ist immer noch etwas potentiell falsch. Hast du Python 2.7 systemweit unter ''/usr'' installiert, zusätzlich zu ''/usr/local''? –