I am trying to install nltk on an Amazon EC2 instance using pip and virtual environment. nltk is listed in the requirements.txt file that pip uses. I also want to download punkt using the nltk.download('punkt') option.
Here's what my makefile looks like:
INSTANCE_NAME=toolsapp
ENV=env
LOAD_ENV=source $(ENV)/bin/activate
VIRTUALENV_BIN:=$(shell which virtualenv || echo /usr/local/bin/virtualenv )
EB_BIN:=$(shell $(LOAD_ENV) && which eb || echo /usr/local/bin/eb )
AWS_BIN:=$(shell $(LOAD_ENV) && which aws || echo /usr/local/bin/aws )
default: dev
.PHONY: default
# Ensure virtualenv is installed
$(VIRTUALENV_BIN):
pip3 install virtualenv
# Create a virtualenv folder called env/ and install dependencies
$(ENV): $(VIRTUALENV_BIN)
virtualenv -p python3 $(ENV)
$(LOAD_ENV) && pip install --upgrade pip && pip install -r requirements.txt
But this is the error I get when I try to run the webapp:
[Tue Jul 24 14:46:13.798460 2018] [:error] [pid 22801] model type: 9
[Tue Jul 24 14:46:13.801193 2018] [:error] [pid 22801] Traceback (most recent call last):
[Tue Jul 24 14:46:13.801227 2018] [:error] [pid 22801] File "/opt/python/run/venv/local/lib/python3.6/site-packages/sumy/nlp/tokenizers.py", line 79, in _get_sentence_tokenizer
[Tue Jul 24 14:46:13.801232 2018] [:error] [pid 22801] return nltk.data.load(path)
[Tue Jul 24 14:46:13.801239 2018] [:error] [pid 22801] File "/opt/python/run/venv/local/lib/python3.6/site-packages/nltk/data.py", line 836, in load
[Tue Jul 24 14:46:13.801242 2018] [:error] [pid 22801] opened_resource = _open(resource_url)
[Tue Jul 24 14:46:13.801247 2018] [:error] [pid 22801] File "/opt/python/run/venv/local/lib/python3.6/site-packages/nltk/data.py", line 954, in _open
[Tue Jul 24 14:46:13.801251 2018] [:error] [pid 22801] return find(path_, path + ['']).open()
[Tue Jul 24 14:46:13.801255 2018] [:error] [pid 22801] File "/opt/python/run/venv/local/lib/python3.6/site-packages/nltk/data.py", line 675, in find
[Tue Jul 24 14:46:13.801259 2018] [:error] [pid 22801] raise LookupError(resource_not_found)
[Tue Jul 24 14:46:13.801274 2018] [:error] [pid 22801] LookupError:
[Tue Jul 24 14:46:13.801278 2018] [:error] [pid 22801] **********************************************************************
[Tue Jul 24 14:46:13.801280 2018] [:error] [pid 22801] Resource \x1b[93mpunkt\x1b[0m not found.
[Tue Jul 24 14:46:13.801283 2018] [:error] [pid 22801] Please use the NLTK Downloader to obtain the resource:
[Tue Jul 24 14:46:13.801285 2018] [:error] [pid 22801]
[Tue Jul 24 14:46:13.801288 2018] [:error] [pid 22801] \x1b[31m>>> import nltk
[Tue Jul 24 14:46:13.801299 2018] [:error] [pid 22801] >>> nltk.download('punkt')
[Tue Jul 24 14:46:13.801301 2018] [:error] [pid 22801] \x1b[0m
[Tue Jul 24 14:46:13.801303 2018] [:error] [pid 22801] Searched in:
[Tue Jul 24 14:46:13.801305 2018] [:error] [pid 22801] - '/home/wsgi/nltk_data'
[Tue Jul 24 14:46:13.801307 2018] [:error] [pid 22801] - '/usr/share/nltk_data'
[Tue Jul 24 14:46:13.801310 2018] [:error] [pid 22801] - '/usr/local/share/nltk_data'
[Tue Jul 24 14:46:13.801312 2018] [:error] [pid 22801] - '/usr/lib/nltk_data'
[Tue Jul 24 14:46:13.801314 2018] [:error] [pid 22801] - '/usr/local/lib/nltk_data'
[Tue Jul 24 14:46:13.801316 2018] [:error] [pid 22801] - '/opt/python/run/venv/nltk_data'
[Tue Jul 24 14:46:13.801318 2018] [:error] [pid 22801] - '/opt/python/run/venv/share/nltk_data'
[Tue Jul 24 14:46:13.801320 2018] [:error] [pid 22801] - '/opt/python/run/venv/lib/nltk_data'
[Tue Jul 24 14:46:13.801322 2018] [:error] [pid 22801] - ''
[Tue Jul 24 14:46:13.801325 2018] [:error] [pid 22801] **********************************************************************
[Tue Jul 24 14:46:13.801327 2018] [:error] [pid 22801]
[Tue Jul 24 14:46:13.801342 2018] [:error] [pid 22801]
[Tue Jul 24 14:46:13.801345 2018] [:error] [pid 22801] During handling of the above exception, another exception occurred:
[Tue Jul 24 14:46:13.801348 2018] [:error] [pid 22801]
[Tue Jul 24 14:46:13.801352 2018] [:error] [pid 22801] Traceback (most recent call last):
[Tue Jul 24 14:46:13.801369 2018] [:error] [pid 22801] File "/opt/python/current/app/summarization.py", line 40, in reform
[Tue Jul 24 14:46:13.801372 2018] [:error] [pid 22801] parser = HtmlParser.from_url(inputFile, Tokenizer("english"))
[Tue Jul 24 14:46:13.801377 2018] [:error] [pid 22801] File "/opt/python/run/venv/local/lib/python3.6/site-packages/sumy/nlp/tokenizers.py", line 67, in __init__
[Tue Jul 24 14:46:13.801380 2018] [:error] [pid 22801] self._sentence_tokenizer = self._get_sentence_tokenizer(tokenizer_language)
[Tue Jul 24 14:46:13.801385 2018] [:error] [pid 22801] File "/opt/python/run/venv/local/lib/python3.6/site-packages/sumy/nlp/tokenizers.py", line 82, in _get_sentence_tokenizer
[Tue Jul 24 14:46:13.801388 2018] [:error] [pid 22801] "NLTK tokenizers are missing. Download them by following command: "
[Tue Jul 24 14:46:13.801397 2018] [:error] [pid 22801] LookupError: NLTK tokenizers are missing. Download them by following command: python -c "import nltk; nltk.download('punkt')"
[Tue Jul 24 14:46:13.801414 2018] [:error] [pid 22801] unable to read https://webapp-input.s3.amazonaws.com/43629be5a07a43029f359abd1340ad08.input.txt?AWSAccessKeyId=ASIAI4UVLLOHEUNNKWNQ&Signature=NBbRoAhFB5mP3SNi3jR6rDcz8LY%3D&x-amz-security-token=FQoDYXdzEHgaDKt%2FFOhHU4UQgQLgdCK3A3amyJ9mziqpLJ01DR5yYqszDzAfi8e9B9Uj1xw9pJw4yDqyF5KFtul7D7o6Xm2qX%2FQvSb9tbnMoW2r8Pur%2FbhlJnhfKFUriT6ggk0THgAgXQWQ8pDOIIMOjn7XZLtFvTfWttukS40VC17geWmEod%2FsO9IZh3LyhN46V%2FdDQo21YZfZFRoQbFHgTd823mnnTLwNoZs51B%2BluwOJ70U22P0K%2FdhzFGVEEGj%2FDiT1oC%2B1aGHQoK4h9JC45%2BqdetOoxZZsdc2z8hxFPQbTW59AT2L4PC2icjkzjJ9prhJvzU25iuZeYoO5tC3SZ1fpNtJ5QCiBYdK1R1c0TRygeOGbev24j5qlTb5DLG4HknH47S6XBMKE%2Fs4EyEo2zNbu%2Fg7QhcebwjJ9%2FMcCpmbMV60H2cj2zMxk8gzV83E%2B19CODShcUQ7WSmNcXj5dyupEJ8SCHRBABBXhOZ8wzMLwU%2BgJy59DTzXl7ZZH1t0LzaOQLPSvjdqu%2FPNGhn1M7K4vVNti93hOCWsK0T3tltg9gfIjFF90gHSawS708WvcyUTmN%2BLD7m3cMJ9B9g9adISSU5d4NS7ohPyX%2FEQMom%2FDc2gU%3D&Expires=1532447173.
Add scripts to download the required models after installing nltk.
python3 -m nltk.downloader punkt
python3 -m nltk.downloader stopwords
Related
Below is the error when I try deploy Django==3.2.12, wagtail==2.16.1, python 3.8.2, mod_wsgi 4.9 on a Debian 11 server. I have a full stack trace at the end.
class SimpleLazyObject(LazyObject):
TypeError: Error when calling the metaclass bases
'property' object is not callable
When I run this on my local dev machine which is a Mac it works just fine. I found someone with the exact same problem but no clarity about how it was resolved.
The resources I have been using to assist are 1, 2, 3, 4. I have tried installing mod_wsgi using pip and as well as from sources. Used various guides for Apache2 config. Upgraded from python 3.8 to 3.9 as well as downgraded to 3.7.
Create interpreter '0.0.0.0|'.
[Tue Mar 29 11:49:06.679710 2022] [wsgi:info] [pid 199764:tid 139683953432320] mod_wsgi (pid=199764): Adding '/var/www/html/portal' to path.
[Tue Mar 29 11:49:06.680057 2022] [wsgi:info] [pid 199764:tid 139683953432320] mod_wsgi (pid=199764): Adding '/var/www/html/portal/portalvenv/lib/python3.8/site-packages' to path.
[Tue Mar 29 11:49:06.689628 2022] [wsgi:info] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] mod_wsgi (pid=199764, process='saida-befree_portal', application='0.0.0.0|'): Loading Python script file '/var/www/html/portal/portal/wsgi.py'.
[Tue Mar 29 11:49:06.705081 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] mod_wsgi (pid=199764): Failed to exec Python script file '/var/www/html/portal/portal/wsgi.py'.
[Tue Mar 29 11:49:06.713633 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] mod_wsgi (pid=199764): Exception occurred processing WSGI script '/var/www/html/portal/portal/wsgi.py'.
[Tue Mar 29 11:49:06.713903 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] Traceback (most recent call last):
[Tue Mar 29 11:49:06.714017 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] File "/var/www/html/portal/portal/wsgi.py", line 12, in <module>
[Tue Mar 29 11:49:06.714210 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] from django.core.wsgi import get_wsgi_application
[Tue Mar 29 11:49:06.714304 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] File "/var/www/html/portal/portalvenv/lib/python3.8/site-packages/django/__init__.py", line 1, in <module>
[Tue Mar 29 11:49:06.717663 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] from django.utils.version import get_version
[Tue Mar 29 11:49:06.717837 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] File "/var/www/html/portal/portalvenv/lib/python3.8/site-packages/django/utils/version.py", line 7, in <module>
[Tue Mar 29 11:49:06.718002 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] from django.utils.regex_helper import _lazy_re_compile
[Tue Mar 29 11:49:06.718072 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] File "/var/www/html/portal/portalvenv/lib/python3.8/site-packages/django/utils/regex_helper.py", line 10, in <module>
[Tue Mar 29 11:49:06.718305 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] from django.utils.functional import SimpleLazyObject
[Tue Mar 29 11:49:06.720700 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] File "/var/www/html/portal/portalvenv/lib/python3.8/site-packages/django/utils/functional.py", line 362, in <module>
[Tue Mar 29 11:49:06.721066 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] class SimpleLazyObject(LazyObject):
[Tue Mar 29 11:49:06.721539 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] TypeError: Error when calling the metaclass bases
[Tue Mar 29 11:49:06.721610 2022] [wsgi:error] [pid 199764:tid 139683953432320] [remote xx.xx.xx.xxx:yyyy] 'property' object is not callable
[Tue Mar 29 11:49:58.057546 2022] [reqtimeout:info] [pid 199765:tid 139683870795520] [client xx.xx.xx.xxx:yyyy] AH01382: Request header read timeout
I had the same issue so i did the following steps:
Remove the apache2 library by using the following command-
sudo apt-get remove python-pip apache2 libapache2-mod-wsgi
Then use the following command to install the correct library-
sudo apt-get install python3-pip apache2 libapache2-mod-wsgi-py3
This solved my error.
in localhost:5000 the script is running without any errors. but when it comes to symlink an error has been thrown to appache log.
[Sun Jun 10 17:07:16.170057 2018] [wsgi:error] [pid 30438] [client 120.29.113.65:32852] mod_wsgi (pid=30438): Exception occurred processing$
[Sun Jun 10 17:07:16.170435 2018] [wsgi:error] [pid 30438] [client 120.29.113.65:32852] Traceback (most recent call last):
[Sun Jun 10 17:07:16.170461 2018] [wsgi:error] [pid 30438] [client 120.29.113.65:32852] File "/var/www/html/salesappserver/app.wsgi", lin$
[Sun Jun 10 17:07:16.170465 2018] [wsgi:error] [pid 30438] [client 120.29.113.65:32852] from api import app as application
[Sun Jun 10 17:07:16.170471 2018] [wsgi:error] [pid 30438] [client 120.29.113.65:32852] File "/var/www/html/salesappserver/api.py", line $
[Sun Jun 10 17:07:16.170474 2018] [wsgi:error] [pid 30438] [client 120.29.113.65:32852] from flask_jwt_extended import JWTManager
[Sun Jun 10 17:07:16.170491 2018] [wsgi:error] [pid 30438] [client 120.29.113.65:32852] ImportError: No module named 'flask_jwt_extended'
[Sun Jun 10 17:07:17.501917 2018] [wsgi:error] [pid 30439] [client 120.29.113.65:32858] mod_wsgi (pid=30439): Target WSGI script '/var/www/$
[Sun Jun 10 17:07:17.501994 2018] [wsgi:error] [pid 30439] [client 120.29.113.65:32858] mod_wsgi (pid=30439): Exception occurred processing$
[Sun Jun 10 17:07:17.502345 2018] [wsgi:error] [pid 30439] [client 120.29.113.65:32858] Traceback (most recent call last):
[Sun Jun 10 17:07:17.502372 2018] [wsgi:error] [pid 30439] [client 120.29.113.65:32858] File "/var/www/html/salesappserver/app.wsgi", lin$
[Sun Jun 10 17:07:17.502376 2018] [wsgi:error] [pid 30439] [client 120.29.113.65:32858] from api import app as application
[Sun Jun 10 17:07:17.502382 2018] [wsgi:error] [pid 30439] [client 120.29.113.65:32858] File "/var/www/html/salesappserver/api.py", line $
[Sun Jun 10 17:07:17.502393 2018] [wsgi:error] [pid 30439] [client 120.29.113.65:32858] from flask_jwt_extended import JWTManager
[Sun Jun 10 17:07:17.502411 2018] [wsgi:error] [pid 30439] [client 120.29.113.65:32858] ImportError: No module named 'flask_jwt_extended'
this is the main problem ImportError: No module named 'flask_jwt_extended' which i already satisfied the requirement in FLASK
(salesappserver) ubuntu#ip-172-31-3-35:~$ pip install flask-jwt-extended
Requirement already satisfied: flask-jwt-extended in ./salesappserver/lib/python3.6/site-packages (3.10.0)
Requirement already satisfied: Flask in ./salesappserver/lib/python3.6/site-packages (from flask-jwt-extended) (1.0.2)
Requirement already satisfied: PyJWT in ./salesappserver/lib/python3.6/site-packages (from flask-jwt-extended) (1.6.4)
Requirement already satisfied: Werkzeug>=0.14 in ./salesappserver/lib/python3.6/site-packages (from flask-jwt-extended) (0.14.1)
Requirement already satisfied: Jinja2>=2.10 in ./salesappserver/lib/python3.6/site-packages (from Flask->flask-jwt-extended) (2.10)
Requirement already satisfied: itsdangerous>=0.24 in ./salesappserver/lib/python3.6/site-packages (from Flask->flask-jwt-extended) (0.24)
Requirement already satisfied: click>=5.1 in ./salesappserver/lib/python3.6/site-packages (from Flask->flask-jwt-extended) (6.7)
Requirement already satisfied: MarkupSafe>=0.23 in ./salesappserver/lib/python3.6/site-packages (from Jinja2>=2.10->Flask->flask-jwt-extended) (1.0)
(salesappserver) ubuntu#ip-172-31-3-35:~$
Please help me. thanks in advance
You are missing flask-jwt-extended module. Get the package by running following command and then try again.
pip install flask-jwt-extended
I'm running a Bitrix server over a CentOS Linux 7.4.1708 machine and I can't manage to get Apache work properly. I've tried restarting the Apache service but it didn't work.
I've checked the system logs via Webadmin and it shows the following:
[Mon Mar 05 03:33:12.118466 2018] [mpm_prefork:notice] [pid 1351]
AH00163: Apache/2.4.6 (CentOS) PHP/7.0.26 OpenSSL/1.0.2k-fips
configured -- resuming normal operations
[Mon Mar 05 03:33:12.118482 2018] [core:notice] [pid 1351] AH00094:
Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Mar 05 11:19:46.641040 2018] [mpm_prefork:notice] [pid 1351]
AH00170: caught SIGWINCH, shutting down gracefully
[Mon Mar 05 11:20:15.021546 2018] [suexec:notice] [pid 1360] AH01232:
suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Mar 05 11:20:15.107376 2018] [so:warn] [pid 1360] AH01574: module
socache_shmcb_module is already loaded, skipping
[Mon Mar 05 11:20:17.068083 2018] [mpm_prefork:notice] [pid 1360]
AH00163: Apache/2.4.6 (CentOS) PHP/7.0.26 OpenSSL/1.0.2k-fips
configured -- resuming normal operations
[Mon Mar 05 11:20:17.068138 2018] [core:notice] [pid 1360] AH00094:
Command line: '/usr/sbin/httpd -f /etc/httpd/conf/httpd-scale.conf -D
FOREGROUND'
[Mon Mar 05 11:36:43.537842 2018] [mpm_prefork:notice] [pid 1360]
AH00170: caught SIGWINCH, shutting down gracefully
[Mon Mar 05 11:37:13.314311 2018] [suexec:notice] [pid 1351] AH01232:
suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Mar 05 11:37:13.351957 2018] [so:warn] [pid 1351] AH01574: module
socache_shmcb_module is already loaded, skipping
[Mon Mar 05 11:37:15.361335 2018] [mpm_prefork:notice] [pid 1351]
AH00163: Apache/2.4.6 (CentOS) PHP/7.0.26 OpenSSL/1.0.2k-fips
configured -- resuming normal operations
[Mon Mar 05 11:37:15.361360 2018] [core:notice] [pid 1351] AH00094:
Command line: '/usr/sbin/httpd -f /etc/httpd/conf/httpd-scale.conf -D
FOREGROUND'
[Mon Mar 05 11:49:01.192086 2018] [mpm_prefork:error] [pid 1351]
AH00161: server reached MaxRequestWorkers setting, consider raising
the MaxRequestWorkers setting
[Mon Mar 05 12:01:13.778293 2018] [mpm_prefork:notice] [pid 1351]
AH00170: caught SIGWINCH, shutting down gracefully
[Mon Mar 05 12:01:43.297586 2018] [suexec:notice] [pid 1383] AH01232:
suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Mar 05 12:01:43.371237 2018] [so:warn] [pid 1383] AH01574: module
socache_shmcb_module is already loaded, skipping
[Mon Mar 05 12:01:44.932973 2018] [mpm_prefork:notice] [pid 1383]
AH00163: Apache/2.4.6 (CentOS) PHP/7.0.26 OpenSSL/1.0.2k-fips
configured -- resuming normal operations
[Mon Mar 05 12:01:44.933001 2018] [core:notice] [pid 1383] AH00094:
Command line: '/usr/sbin/httpd -f /etc/httpd/conf/httpd-scale.conf -D
FOREGROUND'
I don't have any clue on what the problem might be. Apache used to work fine until we installed a Bitrix update on the server.
Any sort of help or comment about this would be much appreciated.
Did you increase the MaxRequestWorkers setting as suggested in the logs?
Find the corresponding file:
grep -Ril MaxRequestWorkers /etc/httpd/
On CentOS usually it is /etc/httpd/conf/httpd.conf. Open the file, increase the value of MaxRequestWorkers and restart the web server for the changes to take effect:
systemctl restart httpd
suddenly i am getting this error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster#kibakibi.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
and in apache error logs
[Fri Jan 19 12:42:15.226845 2018] [core:error] [pid 19115] [client 5.255.250.144:60384] End of script output before headers: index.php
[Fri Jan 19 12:42:17.217114 2018] [:error] [pid 19098] [client 5.188.10.11:51242] EasyApache PHP config file not found: /php.conf.yaml
[Fri Jan 19 12:42:17.217148 2018] [core:error] [pid 19098] [client 5.188.10.11:51242] End of script output before headers: index.php
[Fri Jan 19 12:42:17.221895 2018] [:error] [pid 19098] [client 5.188.10.11:51242] EasyApache PHP config file not found: /php.conf.yaml
[Fri Jan 19 12:42:17.221921 2018] [core:error] [pid 19098] [client 5.188.10.11:51242] End of script output before headers: index.php
[Fri Jan 19 12:42:20.958247 2018] [:error] [pid 19113] [client 54.36.148.28:59462] EasyApache PHP config file not found: /php.conf.yaml
[Fri Jan 19 12:42:20.958275 2018] [core:error] [pid 19113] [client 54.36.148.28:59462] End of script output before headers: index.php
[Fri Jan 19 12:42:20.963483 2018] [:error] [pid 19113] [client 54.36.148.28:59462] EasyApache PHP config file not found: /php.conf.yaml
[Fri Jan 19 12:42:20.963510 2018] [core:error] [pid 19113] [client 54.36.148.28:59462] End of script output before headers: index.php
[Fri Jan 19 12:42:21.772834 2018] [:error] [pid 19089] [client 66.249.66.21:41503] EasyApache PHP config file not found: /php.conf.yaml
[Fri Jan 19 12:42:21.772862 2018] [core:error] [pid 19089] [client 66.249.66.21:41503] End of script output before headers: index.php
[Fri Jan 19 12:42:21.777434 2018] [:error] [pid 19089] [client 66.249.66.21:41503] EasyApache PHP config file not found: /php.conf.yaml
[Fri Jan 19 12:42:21.777458 2018] [core:error] [pid 19089] [client 66.249.66.21:41503] End of script output before headers: index.php
[Fri Jan 19 12:42:21.911961 2018] [:error] [pid 19093] [client 84.201.133.27:54553] EasyApache PHP config file not found: /php.conf.yaml
[Fri Jan 19 12:42:21.911994 2018] [core:error] [pid 19093] [client 84.201.133.27:54553] End of script output before headers: index.php
[Fri Jan 19 12:42:21.917152 2018] [:error] [pid 19093] [client 84.201.133.27:54553] EasyApache PHP config file not found: /php.conf.yaml
[Fri Jan 19 12:42:21.917178 2018] [core:error] [pid 19093] [client 84.201.133.27:54553] End of script output before headers: index.php
[Fri Jan 19 12:42:21.974311 2018] [:error] [pid 19090] [client 5.188.10.11:53661] EasyApache PHP config file not found: /php.conf.yaml
[Fri Jan 19 12:42:21.974334 2018] [core:error] [pid 19090] [client 5.188.10.11:53661] End of script output before headers: index.php
[Fri Jan 19 12:42:21.979110 2018] [:error] [pid 19090] [client 5.188.10.11:53661] EasyApache PHP config file not found: /php.conf.yaml
[Fri Jan 19 12:42:21.979133 2018] [core:error] [pid 19090] [client 5.188.10.11:53661] End of script output before headers: index.php
[Fri Jan 19 12:42:22.944860 2018] [:error] [pid 19115] [client 54.36.149.63:42200] EasyApache PHP config file not found: /php.conf.yaml
[Fri Jan 19 12:42:22.944888 2018] [core:error] [pid 19115] [client 54.36.149.63:42200] End of script output before headers: index.php
[Fri Jan 19 12:42:22.949539 2018] [:error] [pid 19115] [client 54.36.149.63:42200] EasyApache PHP config file not found: /php.conf.yaml
[Fri Jan 19 12:42:22.949562 2018] [core:error] [pid 19115] [client 54.36.149.63:42200] End of script output before headers: index.php
[Fri Jan 19 12:42:23.190276 2018] [:error] [pid 19091] [client 100.43.81.113:55308] EasyApache PHP config file not found: /php.conf.yaml
[Fri Jan 19 12:42:23.190302 2018] [core:error] [pid 19091] [client 100.43.81.113:55308] End of script output before headers: index.php
[Fri Jan 19 12:42:23.194975 2018] [:error] [pid 19091] [client 100.43
I just rebuild the easy apache php settings and everything started working again.
(if you are on local just restart the apache if it does not work reinstall the apache and php services).
I have recompiled python2.7.11 using:
./configure
make
make altinstall
sudo ln -s /usr/local/bin/python2.7 /usr/local/bin/python
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo /usr/local/bin/python
sudo /usr/local/bin/easy_install pip
sudo pip install virtualenv
sudo pip install virtualenvwrapper
source /usr/local/bin/virtualenvwrapper.sh
I have installed django and all the dependencies checking that the pip is located in my new python version
I uninstalled the packaged version of mod_wsgi and
I have linked mod_wsgi to the new version of python by:
./configure --with-python=/usr/local/bin/python
make install
When I restart apache both 2.7.6 and 2.7.11 seem to be started:
[Wed Apr 27 01:46:21.085703 2016] [wsgi:warn] [pid 18410:tid 140116611360640] mod_wsgi: Compiled for Python/2.7.11.
[Wed Apr 27 01:46:21.085775 2016] [wsgi:warn] [pid 18410:tid 140116611360640] mod_wsgi: Runtime using Python/2.7.6.
[Wed Apr 27 01:46:21.086641 2016] [mpm_worker:notice] [pid 18410:tid 140116611360640] AH00292: Apache/2.4.7 (Ubuntu) OpenSSL/1.0.1f mod_wsgi/4.5.2 Python/2.7.6 configured -- resuming normal operations
My httpd.conf looks like:
WSGIPythonHome /home/vagrant/.virtualenvs/django_2.7.11_env
<VirtualHost *:80>
ServerName server.dev
ServerAlias www.server.dev
WSGIDaemonProcess server.dev python-path=/var/www/app:/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages
WSGIProcessGroup server.dev
## Vhost docroot
DocumentRoot "/var/www/app"
Alias "/sitemap.xml" "/var/www/app/static/sitemap.xml"
<Directory /var/www/app/static>
Require all granted
</Directory>
<Directory /var/www/wsgi-scripts>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
## Logging
ErrorLog "/var/log/apache2/av_app_nma_api_error.log"
ServerSignature Off
CustomLog "/var/log/apache2/av_app_nma_api_access.log" combined
WSGIScriptAlias / /var/www/wsgi-scripts/wsgi.py
</VirtualHost>
I am able to run the "hello world" wsgi application even though both versions of python seem to be used. However, when I use the django app I end up with an ImportError that seems to be related to the multiple versions.
[Wed Apr 27 02:34:42.956988 2016] [wsgi:info] [pid 20244:tid 140656494913280] mod_wsgi (pid=20244): Adding '/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages' to path.
[Wed Apr 27 02:34:42.957356 2016] [wsgi:info] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] mod_wsgi (pid=20244, process='server.dev', application='server.dev|'): Loading WSGI script '/var/www/wsgi-scripts/wsgi.py'.
[Wed Apr 27 02:34:42.995218 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] mod_wsgi (pid=20244): Target WSGI script '/var/www/wsgi-scripts/wsgi.py' cannot be loaded as Python module.
[Wed Apr 27 02:34:42.995328 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] mod_wsgi (pid=20244): Exception occurred processing WSGI script '/var/www/wsgi-scripts/wsgi.py'.
[Wed Apr 27 02:34:42.995376 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] Traceback (most recent call last):
[Wed Apr 27 02:34:42.995419 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/var/www/wsgi-scripts/wsgi.py", line 18, in <module>
[Wed Apr 27 02:34:42.995945 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] from django.core.wsgi import get_wsgi_application
[Wed Apr 27 02:34:42.995998 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/core/wsgi.py", line 2, in <module>
[Wed Apr 27 02:34:42.996068 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] from django.core.handlers.wsgi import WSGIHandler
[Wed Apr 27 02:34:42.996109 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 10, in <module>
[Wed Apr 27 02:34:42.996209 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] from django import http
[Wed Apr 27 02:34:42.996249 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/http/__init__.py", line 2, in <module>
[Wed Apr 27 02:34:42.996316 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] from django.http.request import (
[Wed Apr 27 02:34:42.996355 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/http/request.py", line 10, in <module>
[Wed Apr 27 02:34:42.996499 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] from django.core import signing
[Wed Apr 27 02:34:42.996560 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/core/signing.py", line 48, in <module>
[Wed Apr 27 02:34:42.996663 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] from django.utils.crypto import constant_time_compare, salted_hmac
[Wed Apr 27 02:34:42.996705 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/utils/crypto.py", line 8, in <module>
[Wed Apr 27 02:34:42.996792 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] import hmac
[Wed Apr 27 02:34:42.996830 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/usr/local/lib/python2.7/hmac.py", line 8, in <module>
[Wed Apr 27 02:34:42.997049 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] from operator import _compare_digest as compare_digest
[Wed Apr 27 02:34:42.997102 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] ImportError: cannot import name _compare_digest
Reply to #Graham: The make command fails with following:
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libpython2.7.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
apxs:Error: Command failed with rc=65536
.
make: *** [src/server/mod_wsgi.la] Error 1
Try:
make distclean
./configure --with-python=/usr/local/bin/python
LD_RUN_PATH=/usr/local/lib make
sudo make install
The LD_RUN_PATH environment variable when building embeds the directory path containing the correct library into the lookup path for the mod_wsgi.so file.