I try to configure mod_wsgi to access odoo thanks my domain name.
I followed this tutorial.
But when I go to my site I get this error :
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] mod_wsgi (pid=30445): Target WSGI script '/opt/odoo-v9-prod/openerp-wsgi.py' cannot be loaded as Python module.
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] mod_wsgi (pid=30445): Exception occurred processing WSGI script '/opt/odoo-v9-prod/openerp-wsgi.py'.
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] Traceback (most recent call last):
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] File "/opt/odoo-v9-prod/openerp-wsgi.py", line 15, in <module>
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] import openerp
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] File "/opt/odoo-v9-prod/openerp/__init__.py", line 58, in <module>
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] import modules
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] File "/opt/odoo-v9-prod/openerp/modules/__init__.py", line 8, in <module>
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] from . import db, graph, loading, migration, module, registry
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] File "/opt/odoo-v9-prod/openerp/modules/graph.py", line 13, in <module>
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] import openerp.osv as osv
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] File "/opt/odoo-v9-prod/openerp/osv/__init__.py", line 4, in <module>
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] import osv
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] File "/opt/odoo-v9-prod/openerp/osv/osv.py", line 4, in <module>
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] from ..exceptions import except_orm
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] File "/opt/odoo-v9-prod/openerp/exceptions.py", line 15, in <module>
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] from lxml import etree
[Thu Nov 03 16:00:57 2016] [error] [client 176.189.147.89] ImportError: /usr/local/lib/python2.7.9/lib/python2.7/site-packages/lxml/etree.so: undefined symbol: PyUnicodeUCS2_DecodeLatin1
I test my python encodage and it is UCS2.
I reinstalled lxml.
Your mod_wsgi is compiled for a different Python installation than the Python virtual environment you are trying to force it to use, or the Python shared library it is finding. Worse is that what ever it is using was compiled with different width for Unicode character support. You need to uninstall mod_wsgi and reinstall mod_wsgi from source code and compile it against the specific Python version you do want to use, forcing it to use the correct shared library if necessary. You may also want to consider reinstalling your custom Python version to use a configuration which aligns with what is generally regarded as best practice for the platform. Linux system usually use 4 byte Unicode, not 2.
Some stuff for you to read:
http://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html#python-shared-library
http://blog.dscpl.com.au/2015/06/installing-custom-python-version-into.html
Ignore the fact that the latter talks about Docker, all still relevant to normal Python install as well.
Related
I'm experimenting and working on a Flask webpage what's gonna use some data from MySQL database and after a little coding I got internal server error and I don't know why.
After several days I cant work out the problem what can I do for it to work?
I'm using Python3, the server where is hosted is Ubuntu system and I can reach the site via LAN right now with the servers LAN domain (server's name) name that I host via Hyper-V cause I don't have a spare PC for that with Ubuntu on it.
The weird part abut it that when I test it locally on my laptop I wont get the 500 Error only if I want to connect the page what's hosted on the server virtual machine.
Because I don't know where is the problem I uploaded most of the files to GitHub, this gonna be changed of course and later deleted for security reasons but now its easier.
Link: https://github.com/Csabatron99/Webpage
Here is the apache2 error log
[Wed Jul 07 12:42:08.597500 2021] [wsgi:error] [pid 10179] [client fe80::1047:5664:1d7b:6d86:1170] mod_wsgi (pid=10179): Failed to exec Python script file '/var/www/FlaskApp/flaskapp.wsgi'.
[Wed Jul 07 12:42:08.597550 2021] [wsgi:error] [pid 10179] [client fe80::1047:5664:1d7b:6d86:1170] mod_wsgi (pid=10179): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'.
[Wed Jul 07 12:42:08.597762 2021] [wsgi:error] [pid 10179] [client fe80::1047:5664:1d7b:6d86:1170] Traceback (most recent call last):
[Wed Jul 07 12:42:08.597784 2021] [wsgi:error] [pid 10179] [client fe80::1047:5664:1d7b:6d86:1170] File "/var/www/FlaskApp/flaskapp.wsgi", line 7, in <module>
[Wed Jul 07 12:42:08.597788 2021] [wsgi:error] [pid 10179] [client fe80::1047:5664:1d7b:6d86:1170] from FlaskApp import app as application
[Wed Jul 07 12:42:08.597793 2021] [wsgi:error] [pid 10179] [client fe80::1047:5664:1d7b:6d86:1170] File "/var/www/FlaskApp/FlaskApp/__init__.py", line 11, in <module>
[Wed Jul 07 12:42:08.597795 2021] [wsgi:error] [pid 10179] [client fe80::1047:5664:1d7b:6d86:1170] from .dbconnect import connection_db
[Wed Jul 07 12:42:08.597799 2021] [wsgi:error] [pid 10179] [client fe80::1047:5664:1d7b:6d86:1170] File "/var/www/FlaskApp/FlaskApp/dbconnect.py", line 3, in <module>
[Wed Jul 07 12:42:08.597802 2021] [wsgi:error] [pid 10179] [client fe80::1047:5664:1d7b:6d86:1170] import mysql.connector
[Wed Jul 07 12:42:08.597811 2021] [wsgi:error] [pid 10179] [client fe80::1047:5664:1d7b:6d86:1170] ModuleNotFoundError: No module named 'mysql'
[Wed Jul 07 12:42:08.816124 2021] [wsgi:error] [pid 10178] [client fe80::1047:5664:1d7b:6d86:1171] mod_wsgi (pid=10178): Failed to exec Python script file '/var/www/FlaskApp/flaskapp.wsgi'., referer: http://tikva-server-hv/
[Wed Jul 07 12:42:08.816173 2021] [wsgi:error] [pid 10178] [client fe80::1047:5664:1d7b:6d86:1171] mod_wsgi (pid=10178): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'., referer: http://tikva-server-hv/
[Wed Jul 07 12:42:08.816386 2021] [wsgi:error] [pid 10178] [client fe80::1047:5664:1d7b:6d86:1171] Traceback (most recent call last):, referer: http://tikva-server-hv/
[Wed Jul 07 12:42:08.816409 2021] [wsgi:error] [pid 10178] [client fe80::1047:5664:1d7b:6d86:1171] File "/var/www/FlaskApp/flaskapp.wsgi", line 7, in <module>, referer: http://tikva-server-hv/
[Wed Jul 07 12:42:08.816413 2021] [wsgi:error] [pid 10178] [client fe80::1047:5664:1d7b:6d86:1171] from FlaskApp import app as application, referer: http://tikva-server-hv/
[Wed Jul 07 12:42:08.816418 2021] [wsgi:error] [pid 10178] [client fe80::1047:5664:1d7b:6d86:1171] File "/var/www/FlaskApp/FlaskApp/__init__.py", line 11, in <module>, referer: http://tikva-server-hv/
[Wed Jul 07 12:42:08.816426 2021] [wsgi:error] [pid 10178] [client fe80::1047:5664:1d7b:6d86:1171] from .dbconnect import connection_db, referer: http://tikva-server-hv/
[Wed Jul 07 12:42:08.816431 2021] [wsgi:error] [pid 10178] [client fe80::1047:5664:1d7b:6d86:1171] File "/var/www/FlaskApp/FlaskApp/dbconnect.py", line 3, in <module>, referer: http://tikva-server-hv/
[Wed Jul 07 12:42:08.816433 2021] [wsgi:error] [pid 10178] [client fe80::1047:5664:1d7b:6d86:1171] import mysql.connector, referer: http://tikva-server-hv/
[Wed Jul 07 12:42:08.816443 2021] [wsgi:error] [pid 10178] [client fe80::1047:5664:1d7b:6d86:1171] ModuleNotFoundError: No module named 'mysql', referer: http://tikva-server-hv/
and this is the code from the dbconnect.py
import mysql.connector
def connection_db():
conn1 = connector.connect(host="localhost",
user = "root",
passwd = "pass",
db = "db")
c1 = conn1.cursor()
return c1, conn1
Do not download the module I mistook content_management as pip module. you can uninstall the module pip uninstall contentful_management
The error comes because you are importing module in init.py.
try this:
from name_of_the_parent_directory import content_management
You an try using
from . import content_management
name_of_the_parent_directory - means the parent directory, in your github it will be webpage.
I have a Python 2.7 script using NLTK that runs fine on command prompt. When I ran it in a local Apache server on the same machine, it crashes and the error log shows "NotImplementedError: cannot determine number of cpus" while loading scipy. More detailed messages are shown below. Anyone else have the same problem?
.....
[Thu Aug 09 18:07:50 2018] [error] [client ::1] File "interpnd.pyx", line 1, in init scipy.interpolate.interpnd\r, referer: http://localhost/index.html
[Thu Aug 09 18:07:50 2018] [error] [client ::1] File "C:\Anaconda2\lib\site-packages\scipy\spatial\__init__.py", line 95, in \r, referer: http://localhost/index.html
[Thu Aug 09 18:07:50 2018] [error] [client ::1] from .ckdtree import *\r, referer: http://localhost/index.html
[Thu Aug 09 18:07:50 2018] [error] [client ::1] File "ckdtree.pyx", line 31, in init scipy.spatial.ckdtree\r, referer: http://localhost/index.html
[Thu Aug 09 18:07:50 2018] [error] [client ::1] File "C:\Anaconda2\lib\multiprocessing\__init__.py", line 136, in cpu_count\r, referer: http://localhost/index.html
[Thu Aug 09 18:07:50 2018] [error] [client ::1] raise NotImplementedError('cannot determine number of cpus')\r, referer: http://localhost/index.html
[Thu Aug 09 18:07:50 2018] [error] [client ::1] NotImplementedError: cannot determine number of cpus\r, referer: http://localhost/index.html
I am getting below error when I start the httpd server and access the app url -
[Tue Feb 21 22:01:51 2017] [error] [client 10.209.33.139] mod_wsgi (pid=15425): Target WSGI script '/scratch/gdudwadk/python-projects/newblog/app/wsgi.py' cannot be loaded as Python module.
[Tue Feb 21 22:01:51 2017] [error] [client 10.209.33.139] mod_wsgi (pid=15425): Exception occurred processing WSGI script '/scratch/gdudwadk/python-projects/newblog/app/wsgi.py'.
[Tue Feb 21 22:01:51 2017] [error] Traceback (most recent call last):
[Tue Feb 21 22:01:51 2017] [error] File "/scratch/gdudwadk/python-projects/newblog/app/wsgi.py", line 7, in <module>
[Tue Feb 21 22:01:51 2017] [error] from app import app as application
[Tue Feb 21 22:01:51 2017] [error] File "/scratch/gdudwadk/python-projects/newblog/app/app.py", line 1, in <module>
[Tue Feb 21 22:01:51 2017] [error] from flask import Flask
[Tue Feb 21 22:01:51 2017] [error] File "/scratch/gdudwadk/python-projects/newblog/venv/lib/python2.6/site-packages/flask/__init__.py", line 17, in <module>
[Tue Feb 21 22:01:51 2017] [error] from werkzeug.exceptions import abort
[Tue Feb 21 22:01:51 2017] [error] File "/scratch/gdudwadk/python-projects/newblog/venv/lib/python2.6/site-packages/werkzeug/__init__.py", line 17, in <module>
[Tue Feb 21 22:01:51 2017] [error] from types import ModuleType
[Tue Feb 21 22:01:51 2017] [error] ImportError: No module named types
This started happening after my machine was replaced with new one. Previously app was working fine.
I found one reference to python2.7 in /etc/httpd/conf.d/wsgi.conf and that's what was causing the issue. After removing that, the app was up and running.. Thanks!
I am developing a website and want to put some files on the server. The problem is that I can only import python modules ( e.g. "import os"), but somewhy, can not import my own modules:
test1.py:
import test2
test2.py:
print ("Content-type:text/html\n\n")
print ("<html>")
print ("<head>")
print ("<title>Error</title>")
print ("</head>")
print ("<body>")
print (" hello world 2")
print ("</body>")
print ("</html>")
If I click www.mywebsite.com/test2.py, then I recieve "hello world" on the screen.
However, if I click www.mywebsite.com/test1.py, I get "500 internal server error." I found out that it is some problem with not being able to import my modules.
p.s. since I am on a shared server, I can not changes sys path etc....
Here is a trace I got in errors.log:
[Thu Jun 11 00:18:09 2015] [error] [client 85.65.174.249] mod_python (pid=17816, interpreter='delekulator.co.il', phase='PythonHandler', handler='mod_python.cgihandler'): Application error
[Thu Jun 11 00:18:09 2015] [error] [client 85.65.174.249] ServerName: 'delekulator.co.il'
[Thu Jun 11 00:18:09 2015] [error] [client 85.65.174.249] DocumentRoot: '/var/www/vhosts/mywebsite.com/httpdocs'
[Thu Jun 11 00:18:09 2015] [error] [client 85.65.174.249] URI: '/test1.py'
[Thu Jun 11 00:18:09 2015] [error] [client 85.65.174.249] Location: None
[Thu Jun 11 00:18:09 2015] [error] [client 85.65.174.249] Directory: '/var/www/vhosts/mywebsite.com/httpdocs/'
[Thu Jun 11 00:18:09 2015] [error] [client 85.65.174.249] Filename: '/var/www/vhosts/mywebsite.com/httpdocs/test1.py'
[Thu Jun 11 00:18:09 2015] [error] [client 85.65.174.249] PathInfo: ''
[Thu Jun 11 00:18:09 2015] [error] [client 85.65.174.249] Traceback (most recent call last):
[Thu Jun 11 00:18:09 2015] [error] [client 85.65.174.249] File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch\n default=default_handler, arg=req, silent=hlist.silent)
[Thu Jun 11 00:18:09 2015] [error] [client 85.65.174.249] File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1229, in _process_target\n result = _execute_target(config, req, object, arg)
[Thu Jun 11 00:18:09 2015] [error] [client 85.65.174.249] File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1128, in _execute_target\n result = object(arg)
[Thu Jun 11 00:18:09 2015] [error] [client 85.65.174.249] File "/usr/lib/python2.6/dist-packages/mod_python/cgihandler.py", line 96, in handler\n imp.load_module(module_name, fd, path, desc)
[Thu Jun 11 00:18:09 2015] [error] [client 85.65.174.249] File "/var/www/vhosts/mywebsite.com/httpdocs/test1.py", line 1, in <module>\n import test2
[Thu Jun 11 00:18:09 2015] [error] [client 85.65.174.249] ImportError: No module named test2
In the last line, you can see that the server writes "ImportError: No module named test2"
How can I fix it?
From your description, your program did not found your own module, because you did not give your module's path. Now there are two methods to solve it:
Assume your module's path is: /srv/modules/xxxx.py
First you should import your module in your program: import xxxx
command line:Before you run your program with command line, give the path first. command:
export PYTHONPATH=/srv/modules.Then run your program.
add two lines of codes in your program:
import sys
sys.path.append("/srv/modules")
Use any one way above, you should run your program success.I hope this can help you.
Modules should be in the Python path or in the same directory where the executable is.
Then you do like usually
import test2
test2.some_function() # or whatever.
I am getting this in my error log file. Ive been searching for asolution but have found nothing. I am trying to deploy django with mod_wsgi.
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] ImportError: /usr/lib/python2.6/lib-dynload/_functools.so: wrong ELF class: ELFCLASS32
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] mod_wsgi (pid=20219): Target WSGI script '/home/dbs/public_html/test.wsgi' cannot be loaded as Python module.
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] mod_wsgi (pid=20219): Exception occurred processing WSGI script '/home/dbs/public_html/test.wsgi'.
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] Traceback (most recent call last):
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] File "/home/dbs/public_html/test.wsgi", line 6, in <module>
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] import django.core.handlers.wsgi
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] File "/home/dbs/sites/domain.com/django/core/handlers/wsgi.py", line 2, in <module>
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] from threading import Lock
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] File "/usr/lib/python2.6/threading.py", line 13, in <module>
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] from functools import wraps
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] File "/usr/lib/python2.6/functools.py", line 10, in <module>
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] from _functools import partial, reduce
You have the wrong version of the functional module installed. Either install the correct binary version, or use the pure-python version.