Encountering error getting Spacy to load models - amazon-web-services

I've deployed a Django web app in Elastic Beanstalk and I'm trying to implement spacy, yet encountering errors.
I've listed the download link for the en_core_web_sm in my requirements.txt as https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-1.2.0/en_core_web_sm-1.2.0.tar.gz
I'm importing it in my code my calling import en_core_web_sm and later trying to load it with:
nlp = en_core_web_sm.load()
However in my logs from eb I'm getting errors indicating the model isn't loading properly. Am I missing something here? My instance is configured for 2gb of RAM, that might not be enough, but it shouldn't effect the loading of the model, right? Why would it load the tokenizer but not the model?
[Fri Sep 01 04:33:49.276836 2017] [:error] [pid 23201] \x1b[93m Warning: no model found for 'en'\x1b[0m
[Fri Sep 01 04:33:49.276841 2017] [:error] [pid 23201]
[Fri Sep 01 04:33:49.276849 2017] [:error] [pid 23201]
[Fri Sep 01 04:33:49.276851 2017] [:error] [pid 23201] Only loading the 'en' tokenizer.
[Fri Sep 01 04:33:49.276855 2017] [:error] [pid 23201]
[Fri Sep 01 04:33:49.333165 2017] [:error] [pid 23201] Internal Server Error: /webhookmb/
[Fri Sep 01 04:33:49.333187 2017] [:error] [pid 23201] Traceback (most recent call last):
[Fri Sep 01 04:33:49.333189 2017] [:error] [pid 23201] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/exception.py", line 41, in inner
[Fri Sep 01 04:33:49.333192 2017] [:error] [pid 23201] response = get_response(request)
[Fri Sep 01 04:33:49.333194 2017] [:error] [pid 23201] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/base.py", line 187, in _get_response
[Fri Sep 01 04:33:49.333196 2017] [:error] [pid 23201] response = self.process_exception_by_middleware(e, request)
[Fri Sep 01 04:33:49.333198 2017] [:error] [pid 23201] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/base.py", line 185, in _get_response
[Fri Sep 01 04:33:49.333201 2017] [:error] [pid 23201] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Fri Sep 01 04:33:49.333203 2017] [:error] [pid 23201] File "/opt/python/run/venv/lib/python3.4/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
[Fri Sep 01 04:33:49.333205 2017] [:error] [pid 23201] return view_func(*args, **kwargs)
[Fri Sep 01 04:33:49.333216 2017] [:error] [pid 23201] File "/opt/python/run/venv/lib/python3.4/site-packages/django/views/decorators/http.py", line 40, in inner
[Fri Sep 01 04:33:49.333218 2017] [:error] [pid 23201] return func(request, *args, **kwargs)
[Fri Sep 01 04:33:49.333220 2017] [:error] [pid 23201] File "/opt/python/current/app/webhookmb/views.py", line 81, in webhookmb
[Fri Sep 01 04:33:49.333222 2017] [:error] [pid 23201] interpreter = Interpreter.load(metadata, RasaNLUConfig("rasa_nlu/config_spacy.json"))
[Fri Sep 01 04:33:49.333224 2017] [:error] [pid 23201] File "/opt/python/current/app/rasa_nlu/model.py", line 213, in load
[Fri Sep 01 04:33:49.333226 2017] [:error] [pid 23201] component_name, model_metadata.model_dir, model_metadata, **context)
[Fri Sep 01 04:33:49.333228 2017] [:error] [pid 23201] File "/opt/python/current/app/rasa_nlu/components.py", line 310, in load_component
[Fri Sep 01 04:33:49.333229 2017] [:error] [pid 23201] model_metadata, cached_component, **context)
[Fri Sep 01 04:33:49.333231 2017] [:error] [pid 23201] File "/opt/python/current/app/rasa_nlu/registry.py", line 128, in load_component_by_name
[Fri Sep 01 04:33:49.333233 2017] [:error] [pid 23201] return component_clz.load(model_dir, metadata, cached_component, **kwargs)
[Fri Sep 01 04:33:49.333235 2017] [:error] [pid 23201] File "/opt/python/current/app/rasa_nlu/utils/spacy_utils.py", line 99, in load
[Fri Sep 01 04:33:49.333237 2017] [:error] [pid 23201] cls.ensure_proper_language_model(nlp)
[Fri Sep 01 04:33:49.333239 2017] [:error] [pid 23201] File "/opt/python/current/app/rasa_nlu/utils/spacy_utils.py", line 113, in ensure_proper_language_model
[Fri Sep 01 04:33:49.333240 2017] [:error] [pid 23201] "Make sure you have downloaded the correct model (https://spacy.io/docs/usage/).")
[Fri Sep 01 04:33:49.333244 2017] [:error] [pid 23201] Exception: Failed to load spacy language model for lang 'en'. Make sure you have downloaded the correct model (https://spacy.io/docs/usage/).

Related

Open Edx Third Party Login Integration with Keycloak

I am using edx-ironwood.2-6 in ubuntu 18.08. I am also running keycloak 9.0.0. To enable third-party login using Keycloak I am using the python-social-auth library suggested in edx documentation. Since by default keycloak.py was not available in the edx-ironwood, I copied this keycloak.js file at the location
edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_core/backends
Followed all steps written in comments to setup keycloak and added following information in keycloak.py
SECRET = 'client secret'
PUBLIC_KEY = 'publick key from keycloak'
AUTHORIZATION_URL = 'http://localhost:8080/auth/realms/myrealm/protocol/openid-connect/auth'
ACCESS_TOKEN_URL = 'http://localhost:8080/auth/realms/myrealm/protocol/openid-connect/token'
USER_DETAILS_URL = 'http://localhost:8080/auth/realms/myrealm/protocol/openid-connect/userinfo'
Added following line in the lms.env.json
"THIRD_PARTY_AUTH_BACKENDS":[
"social_core.backends.keycloak.KeycloakOAuth2",
"social_core.backends.google.GoogleOAuth2",
"social_core.backends.linkedin.LinkedinOAuth2"
]
In the Django Admin App, Added a Provider
Name: Keycloak
slug: keycloak
site: localhost:81
backend: keycloak
client Id: 'mooc'
Client Secret: 'secret key'
Also Added client secret in lms.auth.json
"SOCIAL_AUTH_OAUTH_SECRETS": {
"keycloak":"14f89ef1-02ff-48ad-825f-8160e515ec8e"
}
In Keycloak client settings, added access type 'confidential', and redirect uri 'http://localhost:81/auth/complete/keycloak/'
After server restart, In edx login page, login button for keycloak appearing but when I am clicking on it in the browser a message is coming There has been a 500 error on the Open Edx Server
In the apache2 log file following error is coming
[Sat Apr 18 17:09:21.212377 2020] [:error] [pid 8143] Traceback (most recent call last):
[Sat Apr 18 17:09:21.212419 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
[Sat Apr 18 17:09:21.212442 2020] [:error] [pid 8143] response = get_response(request)
[Sat Apr 18 17:09:21.212462 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
[Sat Apr 18 17:09:21.212485 2020] [:error] [pid 8143] response = self._get_response(request)
[Sat Apr 18 17:09:21.212506 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
[Sat Apr 18 17:09:21.212526 2020] [:error] [pid 8143] response = self.process_exception_by_middleware(e, request)
[Sat Apr 18 17:09:21.212548 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
[Sat Apr 18 17:09:21.212569 2020] [:error] [pid 8143] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Sat Apr 18 17:09:21.212589 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/utils/decorators.py", line 185, in inner
[Sat Apr 18 17:09:21.212610 2020] [:error] [pid 8143] return func(*args, **kwargs)
[Sat Apr 18 17:09:21.212630 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
[Sat Apr 18 17:09:21.212651 2020] [:error] [pid 8143] response = view_func(request, *args, **kwargs)
[Sat Apr 18 17:09:21.212671 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_django/utils.py", line 49, in wrapper
[Sat Apr 18 17:09:21.212697 2020] [:error] [pid 8143] return func(request, backend, *args, **kwargs)
[Sat Apr 18 17:09:21.212720 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_django/views.py", line 23, in auth
[Sat Apr 18 17:09:21.212742 2020] [:error] [pid 8143] return do_auth(request.backend, redirect_name=REDIRECT_FIELD_NAME)
[Sat Apr 18 17:09:21.212762 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_core/actions.py", line 29, in do_auth
[Sat Apr 18 17:09:21.212783 2020] [:error] [pid 8143] return backend.start()
[Sat Apr 18 17:09:21.212803 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_core/backends/base.py", line 35, in start
[Sat Apr 18 17:09:21.212823 2020] [:error] [pid 8143] return self.strategy.redirect(self.auth_url())
[Sat Apr 18 17:09:21.212844 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_django/strategy.py", line 88, in redirect
[Sat Apr 18 17:09:21.212864 2020] [:error] [pid 8143] return redirect(url)
[Sat Apr 18 17:09:21.212884 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/shortcuts.py", line 56, in redirect
[Sat Apr 18 17:09:21.212904 2020] [:error] [pid 8143] return redirect_class(resolve_url(to, *args, **kwargs))
[Sat Apr 18 17:09:21.212925 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/shortcuts.py", line 147, in resolve_url
[Sat Apr 18 17:09:21.212945 2020] [:error] [pid 8143] return reverse(to, args=args, kwargs=kwargs)
[Sat Apr 18 17:09:21.212965 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/src/django-wiki/wiki/models/__init__.py", line 90, in reverse
[Sat Apr 18 17:09:21.212986 2020] [:error] [pid 8143] url = original_django_reverse(*args, **kwargs)
[Sat Apr 18 17:09:21.213006 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/urls/base.py", line 91, in reverse
[Sat Apr 18 17:09:21.213026 2020] [:error] [pid 8143] return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
[Sat Apr 18 17:09:21.213047 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/urls/resolvers.py", line 497, in _reverse_with_prefix
[Sat Apr 18 17:09:21.213067 2020] [:error] [pid 8143] raise NoReverseMatch(msg)
[Sat Apr 18 17:09:21.213089 2020] [:error] [pid 8143] NoReverseMatch: Reverse for 'None?scope=profile+email&state=yst8UI8KZihrluHg9R0oUFexFIx0QYGM&redirect_uri=http%3A%2F%2Flocalhost%3A81%2Fauth%2Fcomplete%2Fkeycloak%2F%3Fredirect_state%3Dyst8UI8KZihrluHg9R0oUFexFIx0QYGM&response_type=code&client_id=mooc' not found. 'None?scope=profile+email&state=yst8UI8KZihrluHg9R0oUFexFIx0QYGM&redirect_uri=http%3A%2F%2Flocalhost%3A81%2Fauth%2Fcomplete%2Fkeycloak%2F%3Fredirect_state%3Dyst8UI8KZihrluHg9R0oUFexFIx0QYGM&response_type=code&client_id=mooc' is not a valid view function or pattern name.
I tried same third party integration with same python-social-auth for LinkedIn and that is working.
Since I am just a beginner in the Django, Can anyone help me identify the issue from the above details.
After finding and reading many official resources, I haven't found any solution which worked. So I decided to try my own custom file for keycloak.
Here is the link of the file
https://github.com/ranjeet692/python-social-auth-keycloak,
For open edx users, place this file into this directory
/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_core/backends
Follow the rest instruction as mentioned here
Social Auth Documentation
and restart the server. You should be able to login with keycloak.
There is now an official backend for keycloak in python-social-auth:
https://github.com/python-social-auth/social-core/blob/master/social_core/backends/keycloak.py
Just add
"THIRD_PARTY_AUTH_BACKENDS": [
"social_core.backends.keycloak.KeycloakOAuth2"
],
to your lms.env.json
together with the keycloak config:
"SOCIAL_AUTH_KEYCLOAK_KEY": "openedx",
"SOCIAL_AUTH_KEYCLOAK_SECRET": "...",
"SOCIAL_AUTH_KEYCLOAK_PUBLIC_KEY": "...",
"SOCIAL_AUTH_KEYCLOAK_AUTHORIZATION_URL": "https://YOUR_KEYCLOAK/realms/YOUR_REALM/protocol/openid-connect/auth",
"SOCIAL_AUTH_KEYCLOAK_ACCESS_TOKEN_URL": "https://YOUR_KEYCLOAK/realms/YOUR_REALM/protocol/openid-connect/token",
Restart your installation, then go to:
https://YOUR.LMS/admin/third_party_auth/oauth2providerconfig/
and configure according to https://edx.readthedocs.io/projects/edx-installing-configuring-and-running/en/latest/configuration/tpa/tpa_integrate_open/tpa_oauth.html#additional-oauth2-providers-advanced

Internal Server Error Django/apache

My Django app was working fine, but now I'm getting a server error, the last thing I did was a reboot to my Centos7 Server and now I'm getting this error:
and this are my logs I'm using apache:
[Thu Mar 30 14:04:10.571843 2017] [:error] [pid 11335] [remote 10.221.50.100:24] mod_wsgi (pid=11335): Target WSGI script '/opt/btsystem/BTSystem/wsgi.py' cannot be loaded as Python module.
[Thu Mar 30 14:04:10.571991 2017] [:error] [pid 11335] [remote 10.221.50.100:24] mod_wsgi (pid=11335): Exception occurred processing WSGI script '/opt/btsystem/BTSystem/wsgi.py'.
[Thu Mar 30 14:04:10.572263 2017] [:error] [pid 11335] [remote 10.221.50.100:24] Traceback (most recent call last):
[Thu Mar 30 14:04:10.572544 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/opt/btsystem/BTSystem/wsgi.py", line 16, in <module>
[Thu Mar 30 14:04:10.572795 2017] [:error] [pid 11335] [remote 10.221.50.100:24] application = get_wsgi_application()
[Thu Mar 30 14:04:10.572919 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Thu Mar 30 14:04:10.573054 2017] [:error] [pid 11335] [remote 10.221.50.100:24] django.setup(set_prefix=False)
[Thu Mar 30 14:04:10.573107 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/site-packages/django/__init__.py", line 22, in setup
[Thu Mar 30 14:04:10.573170 2017] [:error] [pid 11335] [remote 10.221.50.100:24] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Thu Mar 30 14:04:10.573261 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/site-packages/django/utils/log.py", line 75, in configure_logging
[Thu Mar 30 14:04:10.573312 2017] [:error] [pid 11335] [remote 10.221.50.100:24] logging_config_func(logging_settings)
[Thu Mar 30 14:04:10.573369 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/logging/config.py", line 803, in dictConfig
[Thu Mar 30 14:04:10.573409 2017] [:error] [pid 11335] [remote 10.221.50.100:24] dictConfigClass(config).configure()
[Thu Mar 30 14:04:10.573455 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/logging/config.py", line 585, in configure
[Thu Mar 30 14:04:10.573501 2017] [:error] [pid 11335] [remote 10.221.50.100:24] '%r: %s' % (name, e))
[Thu Mar 30 14:04:10.573567 2017] [:error] [pid 11335] [remote 10.221.50.100:24] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/opt/btsystem-logs/btsystem-debug.log'
Any idea?
The last line shows that Django doesn't have permission to write to the configured log file.
[Thu Mar 30 14:04:10.573567 2017] [:error] [pid 11335] [remote 10.221.50.100:24] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/opt/btsystem-logs/btsystem-debug.log'
Make sure the file /opt/btsystem-logs/btsystem-debug.log is writeable by the user running the Django server.
The main problem was that I needed to do the following to enable the virtual host from Apache:
firewall-cmd --get-active-zones
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
Needed to open the ports.

Can't upload media files from elastic beanstalk/ec2 server

Hey I've been stuck on a problem for a while now where I can upload media files from my localhost to AWS S3, but when I deploy to EB/EC2 I'm getting a 504 gateway timeout when uploading media files. On my development server the uploads work fine and are stored in s3 without any problem.
I'm currently using django-storages but I have tried django-storages-redux and django-s3-storages and I have the same problem where it works on my localhost but on my deployed server I get the 504 Gateway Timeout and the file is not uploaded to s3.
I have my settings files broken out into dev and prod. In my prod settings I have the following:
# S3 FILE SETTINGS
AWS_STORAGE_BUCKET_NAME = 'project-assets'
AWS_S3_CUSTOM_DOMAIN = 'cdn.domain.com'
ASSETS_PREFIX = 'app' # prefix in the bucket
MEDIA_PREFIX = ASSETS_PREFIX + '/uploads/'
DEFAULT_FILE_STORAGE = 'core.storages.MediaStorage'
STATICFILES_STORAGE = 'core.storages.StaticStorage'
To test on development I simply move these settings to the bottom of my dev settings.
I have these custom prefixes to store it in a specific directory on s3.
# storages.py
from django.conf import settings
from storages.backends.s3boto import S3BotoStorage
class StaticStorage(S3BotoStorage):
def __init__(self, *args, **kwargs):
kwargs['location'] = settings.ASSETS_PREFIX
return super(StaticStorage, self).__init__(*args, **kwargs)
class MediaStorage(S3BotoStorage):
def __init__(self, *args, **kwargs):
kwargs['location'] = settings.MEDIA_PREFIX
return super(MediaStorage, self).__init__(*args, **kwargs)
I have gotten this error before on other projects, and it usually had to do with the AWS_REGION. I have tried also using that setting but have the same results. My S3 is stored in 'us-west-2' (default) so as far as I have read I don't need to specify the region.
Here is the stacktrace that appears in my logs when I try to upload on my deployed instance.
Traceback (most recent call last):
File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/exception.py", line 39, in inner
[Tue Sep 27 16:01:31.991596 2016] [:error] [pid 13870] response = get_response(request)
[Tue Sep 27 16:01:31.991598 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/base.py", line 187, in _get_response
[Tue Sep 27 16:01:31.991600 2016] [:error] [pid 13870] response = self.process_exception_by_middleware(e, request)
[Tue Sep 27 16:01:31.991602 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/base.py", line 185, in _get_response
[Tue Sep 27 16:01:31.991604 2016] [:error] [pid 13870] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Tue Sep 27 16:01:31.991606 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
[Tue Sep 27 16:01:31.991608 2016] [:error] [pid 13870] return view_func(*args, **kwargs)
[Tue Sep 27 16:01:31.991609 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/viewsets.py", line 87, in view
[Tue Sep 27 16:01:31.991619 2016] [:error] [pid 13870] return self.dispatch(request, *args, **kwargs)
[Tue Sep 27 16:01:31.991621 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/views.py", line 474, in dispatch
[Tue Sep 27 16:01:31.991623 2016] [:error] [pid 13870] response = self.handle_exception(exc)
[Tue Sep 27 16:01:31.991625 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/views.py", line 434, in handle_exception
[Tue Sep 27 16:01:31.991626 2016] [:error] [pid 13870] self.raise_uncaught_exception(exc)
[Tue Sep 27 16:01:31.991628 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/views.py", line 471, in dispatch
[Tue Sep 27 16:01:31.991630 2016] [:error] [pid 13870] response = handler(request, *args, **kwargs)
[Tue Sep 27 16:01:31.991631 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/mixins.py", line 21, in create
[Tue Sep 27 16:01:31.991633 2016] [:error] [pid 13870] self.perform_create(serializer)
[Tue Sep 27 16:01:31.991634 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/mixins.py", line 26, in perform_create
[Tue Sep 27 16:01:31.991636 2016] [:error] [pid 13870] serializer.save()
[Tue Sep 27 16:01:31.991638 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/serializers.py", line 192, in save
[Tue Sep 27 16:01:31.991639 2016] [:error] [pid 13870] self.instance = self.create(validated_data)
[Tue Sep 27 16:01:31.991641 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/serializers.py", line 873, in create
[Tue Sep 27 16:01:31.991643 2016] [:error] [pid 13870] instance = ModelClass.objects.create(**validated_data)
[Tue Sep 27 16:01:31.991644 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/manager.py", line 85, in manager_method
[Tue Sep 27 16:01:31.991646 2016] [:error] [pid 13870] return getattr(self.get_queryset(), name)(*args, **kwargs)
[Tue Sep 27 16:01:31.991659 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/query.py", line 399, in create
[Tue Sep 27 16:01:31.991661 2016] [:error] [pid 13870] obj.save(force_insert=True, using=self.db)
[Tue Sep 27 16:01:31.991663 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/base.py", line 796, in save
[Tue Sep 27 16:01:31.991665 2016] [:error] [pid 13870] force_update=force_update, update_fields=update_fields)
[Tue Sep 27 16:01:31.991666 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/base.py", line 824, in save_base
[Tue Sep 27 16:01:31.991668 2016] [:error] [pid 13870] updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
[Tue Sep 27 16:01:31.991670 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/base.py", line 908, in _save_table
[Tue Sep 27 16:01:31.991672 2016] [:error] [pid 13870] result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
[Tue Sep 27 16:01:31.991673 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/base.py", line 947, in _do_insert
[Tue Sep 27 16:01:31.991675 2016] [:error] [pid 13870] using=using, raw=raw)
[Tue Sep 27 16:01:31.991677 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/manager.py", line 85, in manager_method
[Tue Sep 27 16:01:31.991679 2016] [:error] [pid 13870] return getattr(self.get_queryset(), name)(*args, **kwargs)
[Tue Sep 27 16:01:31.991680 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/query.py", line 1045, in _insert
[Tue Sep 27 16:01:31.991682 2016] [:error] [pid 13870] return query.get_compiler(using=using).execute_sql(return_id)
[Tue Sep 27 16:01:31.991686 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 1053, in execute_sql
[Tue Sep 27 16:01:31.991688 2016] [:error] [pid 13870] for sql, params in self.as_sql():
[Tue Sep 27 16:01:31.991690 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 1006, in as_sql
[Tue Sep 27 16:01:31.991692 2016] [:error] [pid 13870] for obj in self.query.objs
[Tue Sep 27 16:01:31.991693 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 1006, in <listcomp>
[Tue Sep 27 16:01:31.991695 2016] [:error] [pid 13870] for obj in self.query.objs
[Tue Sep 27 16:01:31.991697 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 1005, in <listcomp>
[Tue Sep 27 16:01:31.991699 2016] [:error] [pid 13870] [self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields]
[Tue Sep 27 16:01:31.991701 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 955, in pre_save_val
[Tue Sep 27 16:01:31.991702 2016] [:error] [pid 13870] return field.pre_save(obj, add=True)
[Tue Sep 27 16:01:31.991704 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/fields/files.py", line 292, in pre_save
[Tue Sep 27 16:01:31.991706 2016] [:error] [pid 13870] file.save(file.name, file, save=False)
[Tue Sep 27 16:01:31.991708 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/fields/files.py", line 91, in save
[Tue Sep 27 16:01:31.991709 2016] [:error] [pid 13870] self.name = self.storage.save(name, content, max_length=self.field.max_length)
[Tue Sep 27 16:01:31.991711 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/files/storage.py", line 54, in save
[Tue Sep 27 16:01:31.991713 2016] [:error] [pid 13870] return self._save(name, content)
[Tue Sep 27 16:01:31.991714 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/storages/backends/s3boto.py", line 413, in _save
[Tue Sep 27 16:01:31.991716 2016] [:error] [pid 13870] self._save_content(key, content, headers=headers)
[Tue Sep 27 16:01:31.991718 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/storages/backends/s3boto.py", line 424, in _save_content
[Tue Sep 27 16:01:31.991720 2016] [:error] [pid 13870] rewind=True, **kwargs)
[Tue Sep 27 16:01:31.991721 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/s3/key.py", line 1293, in set_contents_from_file
[Tue Sep 27 16:01:31.991723 2016] [:error] [pid 13870] chunked_transfer=chunked_transfer, size=size)
[Tue Sep 27 16:01:31.991725 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/s3/key.py", line 750, in send_file
[Tue Sep 27 16:01:31.991727 2016] [:error] [pid 13870] chunked_transfer=chunked_transfer, size=size)
[Tue Sep 27 16:01:31.991728 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/s3/key.py", line 951, in _send_file_internal
[Tue Sep 27 16:01:31.991730 2016] [:error] [pid 13870] query_args=query_args
[Tue Sep 27 16:01:31.991732 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/s3/connection.py", line 668, in make_request
[Tue Sep 27 16:01:31.991734 2016] [:error] [pid 13870] retry_handler=retry_handler
[Tue Sep 27 16:01:31.991735 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/connection.py", line 1071, in make_request
[Tue Sep 27 16:01:31.991737 2016] [:error] [pid 13870] retry_handler=retry_handler)
[Tue Sep 27 16:01:31.991739 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/connection.py", line 1030, in _mexe
[Tue Sep 27 16:01:31.991743 2016] [:error] [pid 13870] raise ex
[Tue Sep 27 16:01:31.991744 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/connection.py", line 940, in _mexe
[Tue Sep 27 16:01:31.991746 2016] [:error] [pid 13870] request.body, request.headers)
[Tue Sep 27 16:01:31.991748 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/s3/key.py", line 844, in sender
[Tue Sep 27 16:01:31.991750 2016] [:error] [pid 13870] http_conn.send(chunk)
[Tue Sep 27 16:01:31.991751 2016] [:error] [pid 13870] File "/usr/lib64/python3.4/http/client.py", line 917, in send
[Tue Sep 27 16:01:31.991753 2016] [:error] [pid 13870] self.sock.sendall(data)
[Tue Sep 27 16:01:31.991755 2016] [:error] [pid 13870] File "/usr/lib64/python3.4/ssl.py", line 723, in sendall
[Tue Sep 27 16:01:31.991756 2016] [:error] [pid 13870] v = self.send(data[count:])
[Tue Sep 27 16:01:31.991758 2016] [:error] [pid 13870] File "/usr/lib64/python3.4/ssl.py", line 684, in send
[Tue Sep 27 16:01:31.991760 2016] [:error] [pid 13870] v = self._sslobj.write(data)
[Tue Sep 27 16:01:31.991763 2016] [:error] [pid 13870] ConnectionResetError: [Errno 104] Connection reset by peer
I thought maybe there was a problem with ssl (everything is on https) and tried setting the AWS_S3_SECURE_URLS = True setting but have the same result.
I've also tried turning off the https redirect and uploading through http:// and have the same result again.
Any ideas are welcome, thanks in advance!
Well, as expected it was something very simple. I didn't load my id/key into the environment variables.

Django-WSGI setup causing permission denied issues on CentOS 7

I'm new in the world of Django. I've been working on setting up WSGI to serve my Django project. It is working fine on my personal machine but on the server I'm having a hard time to setup.
I'm using logging in Django. But it is giving 'permission denied' error. But when I place all my log files in the '/tmp' folder, it works fine.
Similar issue is with the 'db.sqlite3' file (that is my DB file which the Django uses).
Please help me out in resolving the issue.
Following information may be useful to help me out :
OS : CentOS 7
Python : 2.7.5
Apache : 2.4.6
MOD_WSGI : 3.4
Following is the WSGI's error_log:
[Wed Aug 05 01:53:31.661156 2015] [:error] [pid 32177] [remote 192.168.40.142:184] Traceback (most recent call last):
[Wed Aug 05 01:53:31.661192 2015] [:error] [pid 32177] [remote 192.168.40.142:184] File "/var/www/html/portals/wsgi.py", line 18, in <module>
[Wed Aug 05 01:53:31.661254 2015] [:error] [pid 32177] [remote 192.168.40.142:184] application = get_wsgi_application()
[Wed Aug 05 01:53:31.661274 2015] [:error] [pid 32177] [remote 192.168.40.142:184] File "/var/www/html/venv/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Wed Aug 05 01:53:31.661313 2015] [:error] [pid 32177] [remote 192.168.40.142:184] django.setup()
[Wed Aug 05 01:53:31.661330 2015] [:error] [pid 32177] [remote 192.168.40.142:184] File "/var/www/html/venv/lib/python2.7/site-packages/django/__init__.py", line 17, in setup
[Wed Aug 05 01:53:31.661361 2015] [:error] [pid 32177] [remote 192.168.40.142:184] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Wed Aug 05 01:53:31.661378 2015] [:error] [pid 32177] [remote 192.168.40.142:184] File "/var/www/html/venv/lib/python2.7/site-packages/django/utils/log.py", line 86, in configure_logging
[Wed Aug 05 01:53:31.661451 2015] [:error] [pid 32177] [remote 192.168.40.142:184] logging_config_func(logging_settings)
[Wed Aug 05 01:53:31.661483 2015] [:error] [pid 32177] [remote 192.168.40.142:184] File "/usr/lib64/python2.7/logging/config.py", line 803, in dictConfig
[Wed Aug 05 01:53:31.661519 2015] [:error] [pid 32177] [remote 192.168.40.142:184] dictConfigClass(config).configure()
[Wed Aug 05 01:53:31.661537 2015] [:error] [pid 32177] [remote 192.168.40.142:184] File "/usr/lib64/python2.7/logging/config.py", line 585, in configure
[Wed Aug 05 01:53:31.661584 2015] [:error] [pid 32177] [remote 192.168.40.142:184] '%r: %s' % (name, e))
[Wed Aug 05 01:53:31.661643 2015] [:error] [pid 32177] [remote 192.168.40.142:184] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/var/www/html/portals/logs/debug.log'
You need to fix permissions with the chmod command, like this:
chmod 775 /var/www/html/portals/logs/debug.log
chown username:apache /var/www/html/portals/logs/debug.log
If group is www-data,change apache to www-data
If the security not matters.You can try
chmod 777 /var/www/html/portals/logs/debug.log

Django WSGI not working with apache

I'm trying to configure the WSGI in Apache to work with Django but it's not working, when I go to domain.com it gives me an error 500.
But If I start Django using:
python manage.py runserver domain.com:8000
When I go to domain.com:8000 works perfectly so I think It's something about apache and WSGI.
Here you have my WSGI script:
import os
import sys
sys.path.append('/var/www/domain/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'domain.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
My VirtualHost configuration:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName www.domain.com
ServerAdmin info#domain.com
ServerAlias domain.com
DocumentRoot /var/www/domain
WSGIScriptAlias / /var/www/domain/domain.wsgi
#Alias /static/ /var/www/domain/static/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
I'm using Ubuntu 14.04. I tried looking at logs but I have no idea what's wrong.
Logs:
[Thu Sep 25 10:15:09.549670 2014] [:error] [pid 17141] [client 88.12.185.72:65477] mod_wsgi (pid=17141): Exception occurred processing WSGI script '/var/www/domain/domain.wsgi'.
[Thu Sep 25 10:15:09.549722 2014] [:error] [pid 17141] [client 88.12.185.72:65477] Traceback (most recent call last):
[Thu Sep 25 10:15:09.549747 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Thu Sep 25 10:15:09.549880 2014] [:error] [pid 17141] [client 88.12.185.72:65477] response = self.get_response(request)
[Thu Sep 25 10:15:09.549899 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 199, in get_response
[Thu Sep 25 10:15:09.550029 2014] [:error] [pid 17141] [client 88.12.185.72:65477] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Thu Sep 25 10:15:09.550048 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 236, in handle_uncaught_exception
[Thu Sep 25 10:15:09.550075 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return debug.technical_500_response(request, *exc_info)
[Thu Sep 25 10:15:09.550091 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 91, in technical_500_response
[Thu Sep 25 10:15:09.550492 2014] [:error] [pid 17141] [client 88.12.185.72:65477] html = reporter.get_traceback_html()
[Thu Sep 25 10:15:09.550513 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 350, in get_traceback_html
[Thu Sep 25 10:15:09.550539 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return t.render(c)
[Thu Sep 25 10:15:09.550554 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 148, in render
[Thu Sep 25 10:15:09.550984 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return self._render(context)
[Thu Sep 25 10:15:09.551006 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 142, in _render
[Thu Sep 25 10:15:09.551034 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return self.nodelist.render(context)
[Thu Sep 25 10:15:09.551048 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 844, in render
[Thu Sep 25 10:15:09.551071 2014] [:error] [pid 17141] [client 88.12.185.72:65477] bit = self.render_node(node, context)
[Thu Sep 25 10:15:09.551084 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 80, in render_node
[Thu Sep 25 10:15:09.551174 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return node.render(context)
[Thu Sep 25 10:15:09.551192 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 90, in render
[Thu Sep 25 10:15:09.551217 2014] [:error] [pid 17141] [client 88.12.185.72:65477] output = self.filter_expression.resolve(context)
[Thu Sep 25 10:15:09.551231 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 624, in resolve
[Thu Sep 25 10:15:09.551268 2014] [:error] [pid 17141] [client 88.12.185.72:65477] new_obj = func(obj, *arg_vals)
[Thu Sep 25 10:15:09.551284 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", line 769, in date
[Thu Sep 25 10:15:09.551595 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return format(value, arg)
[Thu Sep 25 10:15:09.551615 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 343, in format
[Thu Sep 25 10:15:09.551759 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return df.format(format_string)
[Thu Sep 25 10:15:09.551778 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 35, in format
[Thu Sep 25 10:15:09.551817 2014] [:error] [pid 17141] [client 88.12.185.72:65477] pieces.append(force_text(getattr(self, piece)()))
[Thu Sep 25 10:15:09.551834 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 268, in r
[Thu Sep 25 10:15:09.551857 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return self.format('D, j M Y H:i:s O')
[Thu Sep 25 10:15:09.551871 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 35, in format
[Thu Sep 25 10:15:09.551892 2014] [:error] [pid 17141] [client 88.12.185.72:65477] pieces.append(force_text(getattr(self, piece)()))
[Thu Sep 25 10:15:09.551907 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 85, in force_text
[Thu Sep 25 10:15:09.552021 2014] [:error] [pid 17141] [client 88.12.185.72:65477] s = six.text_type(s)
[Thu Sep 25 10:15:09.552039 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 144, in __text_cast
[Thu Sep 25 10:15:09.552276 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return func(*self.__args, **self.__kw)
[Thu Sep 25 10:15:09.552297 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 83, in ugettext
[Thu Sep 25 10:15:09.552412 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return _trans.ugettext(message)
[Thu Sep 25 10:15:09.552431 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 325, in ugettext
[Thu Sep 25 10:15:09.552686 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return do_translate(message, 'ugettext')
[Thu Sep 25 10:15:09.552706 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 306, in do_translate
[Thu Sep 25 10:15:09.552731 2014] [:error] [pid 17141] [client 88.12.185.72:65477] _default = translation(settings.LANGUAGE_CODE)
[Thu Sep 25 10:15:09.552746 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 209, in translation
[Thu Sep 25 10:15:09.552768 2014] [:error] [pid 17141] [client 88.12.185.72:65477] default_translation = _fetch(settings.LANGUAGE_CODE)
[Thu Sep 25 10:15:09.552782 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 189, in _fetch
[Thu Sep 25 10:15:09.552804 2014] [:error] [pid 17141] [client 88.12.185.72:65477] "The translation infrastructure cannot be initialized before the "
[Thu Sep 25 10:15:09.552830 2014] [:error] [pid 17141] [client 88.12.185.72:65477] AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.
Anyone knows what I'm doing wrong?
Thanks
I discover that the version of Django in my production server is 1.7.0 and in Development server is 1.6.4. After downgrade Django works fine.
sudo pip install django==1.6.4