I am trying to migrate my Python Django web app on hosting from the local environment. The installation went well, but at the end I do not see the starting page for Django here staging.changerz.education. In the logs I found the error and not sure what is a problem that I need to fix in my app. Please, help anyone:
"error" : {
"category" : "INTERNAL_ERROR",
"id" : "23a01cfb",
"problem_description_html" : "<p>The Phusion Passenger application server tried to start the web application. But the application itself (and not Passenger) encountered an internal error.</p><p>The stdout/stderr output of the subprocess so far is:</p><pre>Traceback (most recent call last):\n File "/usr/share/passenger/helper-scripts/wsgi-loader.py", line 369, in <module>\n app_module = load_app()\n File "/usr/share/passenger/helper-scripts/wsgi-loader.py", line 76, in load_app\n return imp.load_source('passenger_wsgi', startup_file)\n File "/var/www/u1115154/data/www/staging.changerz.education/passenger_wsgi.py", line 6, in <module>\n from django.core.wsgi import get_wsgi_application\n File "/var/www/u1115154/data/djangoenv/lib/python3.7/site-packages/django/__init__.py", line 1, in <module>\n from django.utils.version import get_version\n File "/var/www/u1115154/data/djangoenv/lib/python3.7/site-packages/django/utils/version.py", line 71, in <module>\n #functools.lru_cache()\nAttributeError: 'module' object has no attribute 'lru_cache'\n</pre>",
"solution_description_html" : "<p class=\"sole-solution\">Unfortunately, Passenger does not know how to solve this problem. Please try troubleshooting the problem by studying the <strong>error message</strong> and the <strong>diagnostics</strong> reports. You can also consult the Passenger support resources for help.</p>",
"summary" : "The application process exited prematurely."
},
Just figured out that the Python version was different from what I have in the virtual environment, so it is worth checking the Python version on the hosting provider side.
Related
I am starting out working on looking into using Python for some Cisco CUCM automation. I found the plugin ciscoaxl here, I installed it and programed the following script:
from ciscoaxl import axl
cucm = "10.10.20.1"
username = "axlusr"
password = "password1"
version = "12.5"
ucm = axl(username, password, cucm, version)
for phone in ucm.get_phones():
print(phone.name)
I am connected to Cisco's DevNET Sandbox and all the login and configuration for the AXL user appear to be correct, however I get the following output when I attempt to run the script:
Traceback (most recent call last):
File "%home%\AppData\Local\Programs\Python\Python39\axl-test.py", line 7, in <module>
for phone in ucm.get_phones():
File "%home%\AppData\Local\Programs\Python\Python39\lib\site-packages\ciscoaxl\axl.py", line 1877, in get_phones
for each in inner(skip):
File "%home%\AppData\Local\Programs\Python\Python39\lib\site-packages\ciscoaxl\axl.py", line 1869, in inner
res = self.client.listPhone(
File "%home%\AppData\Local\Programs\Python\Python39\lib\site-packages\zeep\proxy.py", line 40, in __call__
return self._proxy._binding.send(
File "%home%\AppData\Local\Programs\Python\Python39\lib\site-packages\zeep\wsdl\bindings\soap.py", line 130, in send
return self.process_reply(client, operation_obj, response)
File "%home%\AppData\Local\Programs\Python\Python39\lib\site-packages\zeep\wsdl\bindings\soap.py", line 195, in process_reply
return self.process_error(doc, operation)
File "%home%\AppData\Local\Programs\Python\Python39\lib\site-packages\zeep\wsdl\bindings\soap.py", line 283, in process_error
raise Fault(
zeep.exceptions.Fault: Unknown fault occured
I have run it on Windows10 in an IDLE enviornment, from the Linux-Subsystem (Ubuntu 20.04) via python and ipython3.
After some additional research this is a know issue with CUCM 12.5. It should be fixed in CU1 see here: https://github.com/mvantellingen/python-zeep/issues/989
I still receive this error on 12.5.1.12900-115, but I receive it when I don't have the appropriate permissions. Fixing user permissions for AXL access resolves it.
Whenever I try to deploy my Alexa Skill (for the Amazon Promotion) I see this error when I go to the web address of the endpoint:
"{'message': 'An uncaught exception happened while servicing this request. You can investigate this with the `zappa tail` command.', 'traceback': ['Traceback (most recent call last):\\n', ' File \"/var/task/handler.py\", line 433, in handler\\n response = Response.from_app(self.wsgi_app, environ)\\n', ' File \"/var/task/werkzeug/wrappers.py\", line 903, in from_app\\n return cls(*_run_wsgi_app(app, environ, buffered))\\n', ' File \"/var/task/werkzeug/test.py\", line 884, in run_wsgi_app\\n app_rv = app(environ, start_response)\\n', \"TypeError: 'NoneType' object is not callable\\n\"]}"
After investigating this further, I ran zappa tail to see what the issue is.
I scrolled up through the tail and noticed this error message:
[1499529414189] libssl.so.1.0.0: cannot open shared object file: No such file or directory: ImportError
What does this mean? How can I resolve this? I'm working on Ubuntu 14.04, Python 3.6 using flask-ask.
I was only able to correct this my installing everything from scratch according the instructions at https://developer.amazon.com/blogs/post/8e8ad73a-99e9-4c0f-a7b3-60f92287b0bf/new-alexa-tutorial-deploy-flask-ask-skills-to-aws-lambda-with-zappa. Something in the venv directory just got messed up.
I'm building a website using Flask in which I use MongoDB with the MongoEngine ORM. To go for a fresh start again I now upgraded all apt and pip packages on my ubuntu 14.04 development machine. Unfortunately this broke my connection to MongoDB:
Traceback (most recent call last):
File "./run.py", line 4, in <module>
from app import app, socketio
File "/home/kr65/beta/app/__init__.py", line 21, in <module>
mongoDb = MongoEngine(app)
File "/usr/local/lib/python2.7/dist-packages/flask_mongoengine/__init__.py", line 33, in __init__
self.init_app(app)
File "/usr/local/lib/python2.7/dist-packages/flask_mongoengine/__init__.py", line 66, in init_app
self.connection = mongoengine.connect(**conn_settings)
File "/usr/local/lib/python2.7/dist-packages/mongoengine/connection.py", line 164, in connect
return get_connection(alias)
File "/usr/local/lib/python2.7/dist-packages/mongoengine/connection.py", line 126, in get_connection
raise ConnectionError("Cannot connect to database %s :\n%s" % (alias, e))
mongoengine.connection.ConnectionError: Cannot connect to database default :
False is not a read preference.
I checked if MongoDB is up:
$ sudo service mongodb status
mongodb start/running, process 781
and if I could get into the interactive command line:
$ mongo
MongoDB shell version: 2.4.9
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings:
Tue Apr 14 09:14:10.267 [initandlisten]
Tue Apr 14 09:14:10.267 [initandlisten] ** WARNING: You are running in OpenVZ. This is known to be broken!!!
Tue Apr 14 09:14:10.267 [initandlisten]
>
I didn't change anything to the code or passwords or anything like that. I did a reboot and restarted mongoDB, but nothing works. My settings are like this:
MONGODB_SETTINGS = {
'db': 'mydatabasename'
}
and I instantiate the connection like this (which worked before):
app = Flask(__name__)
app.config.from_object('config')
mongoDb = MongoEngine(app)
Since I didn't really change anything, I'm kind of unsure where to search for a solution. Does anybody have any tips how I could solve this?
[EDIT]
With the tip of #lapinkoira my MongoDB now starts up correctly, but I now get the error below while querying. Any ideas how to solve this one?
File "/home/kr65/beta/app/views/webviews.py", line 476, in getDoc
userDoc = UserDocument.objects(id=docId).first()
File "/usr/local/lib/python2.7/dist-packages/mongoengine/queryset/base.py", line 309, in first
result = queryset[0]
File "/usr/local/lib/python2.7/dist-packages/mongoengine/queryset/base.py", line 160, in __getitem__
return queryset._document._from_son(queryset._cursor[key],
File "/usr/local/lib/python2.7/dist-packages/mongoengine/queryset/base.py", line 1410, in _cursor
**self._cursor_args)
File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 924, in find
return Cursor(self, *args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'snapshot'
looks like you have pymongo 3.0 installed.
Mongoengine is not yet compatible with it.
You can try fix this by
pip uninstall pymongo
pip install pymongo==2.8
Looks like your default read_preference value is False, try this, add to your imports:
from pymongo import read_preferences
and this to your mongo config dictionary:
'read_preference': read_preferences.ReadPreference.PRIMARY
If using monogengine >= 3 and python >=3 and Ubuntu
Write
from pymongo import read_preferences in /usr/local/lib/python3.5/dist-packages/mongoengine/
and open terminal in the same directory with sudo gedit connection.py
and in def register_connection
replace
'read_preference': read_preferences.ReadPreference.PRIMARY in parameters of the function
And it works like charm
I am trying to use lettuce to implement BDD for creating an rest framework api but when I execute the command python manage.py harvest I get following error
/rest_framework/serializers.py", line 818, in get_related_field
'queryset': related_model._default_manager,
AttributeError: 'NoneType' object has no attribute '_default_manager'
Detailed stack trace is:
(envSamplePayApp)root#ubuntu:/pythonWorkspace/samplePayProject# python manage.py harvest
Django's builtin server is running at 0.0.0.0:8000
Traceback (most recent call last):
File "/pythonWorkspace/samplePayProject/envSamplePayApp/local/lib/python2.7/site-packages/lettuce/django/management/commands/harvest.py", line 167, in handle
result = runner.run()
File "/pythonWorkspace/samplePayProject/envSamplePayApp/local/lib/python2.7/site-packages/lettuce/__init__.py", line 137, in run
self.loader.find_and_load_step_definitions()
File "/pythonWorkspace/samplePayProject/envSamplePayApp/local/lib/python2.7/site-packages/lettuce/fs.py", line 49, in find_and_load_step_definitions
module = __import__(to_load)
File "/pythonWorkspace/samplePayProject/envSamplePayApp/local/lib/python2.7/site-packages/rest_framework/tests/test_serializer_import.py", line 4, in <module>
from rest_framework.tests.accounts.serializers import AccountSerializer
File "/pythonWorkspace/samplePayProject/envSamplePayApp/local/lib/python2.7/site-packages/rest_framework/tests/accounts/serializers.py", line 6, in <module>
class AccountSerializer(serializers.ModelSerializer):
File "/pythonWorkspace/samplePayProject/envSamplePayApp/local/lib/python2.7/site-packages/rest_framework/tests/accounts/serializers.py", line 8, in AccountSerializer
admins = UserSerializer(many=True)
File "/pythonWorkspace/samplePayProject/envSamplePayApp/local/lib/python2.7/site-packages/rest_framework/serializers.py", line 196, in __init__
self.fields = self.get_fields()
File "/pythonWorkspace/samplePayProject/envSamplePayApp/local/lib/python2.7/site-packages/rest_framework/serializers.py", line 232, in get_fields
default_fields = self.get_default_fields()
File "/pythonWorkspace/samplePayProject/envSamplePayApp/local/lib/python2.7/site-packages/rest_framework/serializers.py", line 716, in get_default_fields
field = self.get_related_field(model_field, related_model, to_many)
File "/pythonWorkspace/samplePayProject/envSamplePayApp/local/lib/python2.7/site-packages
All the code can be found at downloadcode.
Note when I run the api from browser it works fine.
What is causing the AttributeError: 'NoneType' object has no attribute '_default_manager'?
I ran into this error just now. The cause of my error was due to the fact that I had created a ManyToManyField from Model X of App A to Model Y of App B. When I tried to create schema migration via python manage.py schemamigration --auto app_a, it raised this error because I had yet to:
include 'app_b' in the INSTALLED_APPS tuple of settings.py
not having created the initial schema migration for app_b (which would not be possible with adding app_b to INSTALLED_APPS).
Effectively, I linked to an model that was not known at the time. Hopefully this can help someone in the future.
EDIT: Actually, on further inspection, I realize now the reason that this error is being raised so ambiguously is because of django-debug-toolbar. Apparently DjangoDebugToolbar is causing some issues around errors propagating properly. Disabling it in INSTALLED_APPS allowed the errors to become apparent.
I am trying to use twisted but when i try to run some of the example code provided with the twisted package, it seems to always crash when i use "twistd" instead of "python"
for example, using the example code given with twisted,
if i run to command : twisted -ny echoserv.py
Unhandled Error
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/twisted/application/app.py", line 652, in run
runApp(config)
File "/usr/lib/python2.7/site-packages/twisted/scripts/twistd.py", line 23, in runApp
_SomeApplicationRunner(config).run()
File "/usr/lib/python2.7/site-packages/twisted/application/app.py", line 386, in run
self.application = self.createOrGetApplication()
File "/usr/lib/python2.7/site-packages/twisted/application/app.py", line 451, in createOrGetApplication
application = getApplication(self.config, passphrase)
--- ---
File "/usr/lib/python2.7/site-packages/twisted/application/app.py", line 462, in getApplication
application = service.loadApplication(filename, style, passphrase)
File "/usr/lib/python2.7/site-packages/twisted/application/service.py", line 405, in loadApplication
application = sob.loadValueFromFile(filename, 'application', passphrase)
File "/usr/lib/python2.7/site-packages/twisted/persisted/sob.py", line 211, in loadValueFromFile
value = d[variable]
exceptions.KeyError: 'application'
Failed to load application: 'application'
Could not find 'application' in the file. To use 'twistd -y', your .tac
file must create a suitable object (e.g., by calling service.Application())
and store it in a variable named 'application'. twistd loads your .tac file
and scans the global variables for one of this name.
Please read the 'Using Application' HOWTO for details.
I was using Twisted version 11.0.0 but then i tried 12.0.0 but i have the same problem.
The version of python i am using is 2.7.2
Any ideas on what to do would be helpful. I have been trying to deal with this problem for a few days now. thanks!
twistd -y is meant to be used with a python file that contains a variable called application, there is none in this file, so it's not going to work.
You might want to spend some time reading twistd's documentation so you get a clearer idea of its role in the twisted ecosystem.
To use 'twistd -y', your .tac file must create a suitable object (e.g., by calling service.Application()) and store it in a variable named 'application'. twistd loads your .tac file and scans the global variables for one of this name.
Please read the 'Using Application' HOWTO for details.