I'm upgrading a django app from v1.3 to 1.11.18.
We are running Python v2.7.12 and running an nginx server to serve the pages.
I've been making code changes to account for all of the deprecated methods as a result of the upgrade. So far, so good. After making another run of updates, I ran into this error notice after starting the server:
File "/home/bat/application.com/wsgi.py", line 12, in <module>
application = get_wsgi_application()
File "./django/core/wsgi.py", line 14, in get_wsgi_application
return WSGIHandler()
File "./django/core/handlers/wsgi.py", line 151, in __init__
self.load_middleware()
File "./django/core/handlers/base.py", line 56, in load_middleware
mw_class = import_string(middleware_path)
File "./django/utils/module_loading.py", line 20, in import_string
module = import_module(module_path)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "./django/middleware/locale.py", line 4, in <module>
from django.conf.urls.i18n import is_language_prefix_patterns_used
File "./django/conf/urls/i18n.py", line 2, in <module>
from django.conf.urls import url
ImportError: cannot import name url
I'm not sure why I would be getting this error as the code referenced is all core code. It doesn't appear to be referencing any of the project code at all, except for the opening line.
I've double-checked to be sure we do not have any "left over" code sitting in the core django folder: it's clean. We also rebooted the linux server just for kicks: that didn't help either. Beyond that I'm not really sure what else to try?
Any ideas where I might look for a solution to this one?
So it turns out that the ./django/conf/urls/__init__.py file is actually MISSING the required def url() function. I'm not sure how that didn't get noticed before by anyone, as the core code clearly calls that url function all over the place.
To resolve that issue, I downloaded Django v1.10.x and copied the def url(...) function from the v1.10.x code into the django/conf/urls/__init__.py file and everything worked as expected.
I do realize that I modified a core file, but I wasn't sure how to get around the issue otherwise. This 1.x branch of Django is not under active development, so I figure that's probably okay.
Related
After upgrading to Wagtail 2.15 (or 2.15.1) from 2.14.2 my production website with postgres and database search breaks and commands that are run with manage.py give an error despite me adding the required WAGTAILSEARCH_BACKENDS to settings.
I have two web apps with separate settings running from the same Wagtail version. One of the apps (putkeep) has a search bar and the other (secretgifter) does not. After upgrading Wagtail from 2.14.2 to 2.15, putkeep gives a 404 error but secretgifter does not. If I use pip to switch back to 2.14.2, then the 404 error goes away and the site loads (although results from a search give a 500 error).
If I run makemigrations (or any other command that uses manage.py) for secretgifter it works fine. For putkeep (with the search) it gives the following error:
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
django.setup()
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/django/apps/registry.py", line 122, in populate
app_config.ready()
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/wagtail/search/apps.py", line 21, in ready
set_weights()
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/wagtail/search/backends/database/postgres/weights.py", line 44, in set_weights
BOOSTS_WEIGHTS.extend(determine_boosts_weights())
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/wagtail/search/backends/database/postgres/weights.py", line 32, in determine_boosts_weights
boosts = get_boosts()
File "/home/th-putkeep.net/putkeep/lib/python3.8/site-packages/wagtail/search/backends/database/postgres/weights.py", line 26, in get_boosts
boosts.add(boost)
TypeError: unhashable type: 'list'
As per the docs I've added this to my settings:
WAGTAILSEARCH_BACKENDS = {
'default': {
'BACKEND': 'wagtail.search.backends.database',
}
}
Any suggestions gratefully received.
I have identified some code in my models.py that caused no errors with my site running Wagtail 2.14.2 and below. When commented out, it resolves the error caused by upgrading to Wagtail 2.15 and above. I am posting it here as the answer to my problem because everything else seems to work (including search) without any further modification even though I am not currently sure why it causes the error or if I need it anymore:
search_fields = Page.search_fields + [ # Inherit search_fields from Page
index.SearchField('content'),
index.SearchField('tags', [
index.SearchField('name', partial_match=True, boost=10),
]),
]
I think the issue is with your configuration that is trying to search tag names:
index.SearchField('tags', [
index.SearchField('name', partial_match=True, boost=10),
]),
The default database search doesn't appear to offer an option to search related objects this way (See note under https://docs.wagtail.io/en/stable/topics/search/indexing.html#indexing-callables-and-other-attributes). You can either remove those lines or, for the moment, go back to the postgres_search backend in wagtail/contrib.
Need a Suggestion on the below. I was trying to do a DMS to aurora and i have installed python3.8.8. I have installed all required modules. Openssl is also installed.
When i trigger the script i encounter the below error.
Traceback (most recent call last): File "task_runner.py", line 2, in
import boto3 File "/usr/local/lib/python3.8/site-packages/boto3/init.py", line 16,
in
from boto3.session import Session File "/usr/local/lib/python3.8/site-packages/boto3/session.py", line 17, in
import botocore.session File "/usr/local/lib/python3.8/site-packages/botocore/session.py", line 30,
in
import botocore.credentials File "/usr/local/lib/python3.8/site-packages/botocore/credentials.py", line
34, in
from botocore.config import Config File "/usr/local/lib/python3.8/site-packages/botocore/config.py", line 16,
in
from botocore.endpoint import DEFAULT_TIMEOUT, MAX_POOL_CONNECTIONS File
"/usr/local/lib/python3.8/site-packages/botocore/endpoint.py", line
22, in
from botocore.awsrequest import create_request_object File "/usr/local/lib/python3.8/site-packages/botocore/awsrequest.py", line
26, in
import botocore.utils File "/usr/local/lib/python3.8/site-packages/botocore/utils.py", line 33,
in
import botocore.httpsession File "/usr/local/lib/python3.8/site-packages/botocore/httpsession.py", line
8, in
from urllib3.util.ssl_ import ( ImportError: cannot import name 'ssl' from 'urllib3.util.ssl_'
(/usr/local/lib/python3.8/site-packages/urllib3/util/ssl_.py)
I have tried changing the version of python as suggested in another post and also reinstalled awscli but nothing works. no matter what version of python used, i always end up with the same error.
Lastly, the server where am doing this doesnt have an internet connection.
Kindly suggest.
Cleaning up the entire Python setup and editing the Setup.dist to use SSL during build resolved the issue.
I'm trying to intall the asterisk_click2dial module on ODOO and this error comes to me in the log file:
ValueError: Routing: posting a message without model should be with a parent_id (private mesage).
2015-03-09 15:23:38,262 11093 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
File "/home/odoo/odoo/lib/python2.7/site-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/home/odoo/odoo/lib/python2.7/site-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/opt/odoo/openerp/service/server.py", line 281, in app
return self.app(e, s)
File "/opt/odoo/openerp/service/wsgi_server.py", line 216, in application
return application_unproxied(environ, start_response)
File "/opt/odoo/openerp/service/wsgi_server.py", line 202, in application_unproxied
result = handler(environ, start_response)
File "/opt/odoo/openerp/http.py", line 1274, in __call__
self.load_addons()
File "/opt/odoo/openerp/http.py", line 1293, in load_addons
m = __import__('openerp.addons.' + module)
File "/opt/odoo/openerp/modules/module.py", line 79, in load_module
mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)
File "/opt/odoo/addons/base_phone/__init__.py", line 23, in <module>
from . import wizard
File "/opt/odoo/addons/base_phone/wizard/__init__.py", line 23, in <module>
from . import number_not_found
File "/opt/odoo/addons/base_phone/wizard/number_not_found.py", line 25, in <module>
import phonenumbers
ImportError: No module named phonenumbers
The problem is just that I installed that module (phonenumbers) plus the py-Asterisk module without errors using pip install phonenumbers and pip install py-Asterisk and the error persists.
I noticed I have at least two versions of python installed (2.6 and 2.7) but both modules are installed at the same version from odoo (I can see the modules in the python2.7 cli when, for example, I write phonenumbers or search).
Has anybody any idea what is happening to me? I'd be gratefull for some specific response. Thanks.
Here the connector's page: OpenERP - Asterisk connector
Ok, my bad. During odoo instalation I created a virtual environment under the Odoo system user account which was used solely by the Odoo server so I just need to install these modules under that enviorment. This works for me:
First let’s switch from root to the odoo user, then create a new virtual environment called odoo and activate it:
su - odoo
/usr/local/bin/virtualenv --python=/usr/local/bin/python2.7 odoo
source odoo/bin/activate
(If you have the virtual environment created like me just ignore the second line). Before starting the module installation we need to add the path to the PostgreSQL binaries, otherwise the PsycoPG2 module install will fail (I ignored this one too):
export PATH=/usr/pgsql-9.3/bin:$PATH
Then I can do pip install... Thank you all for your help.
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/Library/Python/2.7/site-packages/dj_static.py", line 83, in __call__
return self.application(environ, start_response)
File "/Library/Python/2.7/site-packages/django/core/handlers/wsgi.py", line 255, in __call__
response = self.get_response(request)
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 178, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 220, in handle_uncaught_exception
if resolver.urlconf_module is None:
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 342, in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Users/WillRedington/Desktop/Django Projects/propadev/propvocab/urls.py", line 3, in <module>
from rest_framework import routers
File "/Library/Python/2.7/site-packages/rest_framework/routers.py", line 23, in <module>
from rest_framework import views
File "/Library/Python/2.7/site-packages/rest_framework/views.py", line 11, in <module>
from rest_framework.compat import HttpResponseBase, View
File "/Library/Python/2.7/site-packages/rest_framework/compat.py", line 13, in <module>
from django.utils.six.moves.urllib import parse as urlparse
ImportError: No module named urllib
The server error message: [17/Dec/2014 16:26:45] "GET / HTTP/1.1" 500 59
This is checking if python returns the modules:
>>> import django.utils.six.moves
>>> import django.utils.six.moves.urllib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named urllib
>>>
My current python version is 2.7.2, Django is 1.5.1, rest framework is in 2.7 site-package.
I have already tried uninstalling and reinstalling Django several times and get the same error.
This is running on Mac OS X 10.9.5, please help me, I've been at this for 5 hours.
it seems like a dependency error. Maybe you downgraded your django, or randomly installed the rest framework package without controlling the dependencies.
django.utils.six.moves.urllib doesnt exist in django==1.5.1 yet. You can try to upgrade django to 1.5.7 for example. Then this import will work. Other things might still be broken though, I can´t tell from here. If you post the output of pip freeze here, it may be easier to help.
You aren´t working in a virtual environment, which is dangerous for dependencies. Best is to make a virtualenv, then install your packages with pip, taking care of dependencies.
Then run:
pip freeze > requirements.txt
and use that file in the future like this:
pip install -r requirements.txt
and edit the file accordingly if you install, update or remove packages.
Something that might be of interest is this: it generally never works to uninstall and reinstall the same package several times; if it doesn´t work once, it won´t work the second time either.
As someone mentioned before my response wasn't really an answer. I solved this error and potentially many more by installing a python virtual environment. To do this run the following
sudo pip install virtualenv
Then create a new folder for your virtual environments. cd into the created folder.
cd myvirtualenv
Then create a new virtual environment by running the following:
virtualenv venv
To run the virtual env:
source venv/bin/activate
This makes a seperate environment with it's own site packages, which is essential for any python developer, especially when working on multiple projects.
Source: http://docs.python-guide.org/en/latest/dev/virtualenvs/
I'd like to put a flickr feed on my homepage using django-syncr; I followed the instructions on the homepage (http://code.google.com/p/django-syncr/), and the installation process was pretty smooth. Steps 1-3 work just fine, but Step 4 is where I run into problems.
When I try to run the commands shown:
from syncr.app.flickr import FlickrSyncr
I get the error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/django_syncr-0.50-py2.7.egg/sync/app/flickr.py", line 11, in <module>
from syncr.flickr.models import *
File "/usr/local/lib/python2.7/dist-packages/django_syncr-0.50-py2.7.egg/syncr/flickr/models.py", line 1, in <module>
from django.db import models
File "/usr/lib/python2.7/dist-packages/django/db/__init__.py", line 14, in <module>
if not settings.DATABASES:
File "/usr/lib/python2.7/dist-packages/django/utils/functional.py", line 276, in __getattr__self._setup()
File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 40, in _setup
raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
And I'm not really sure what to do. These files are run in my django project folder, but including the settings file (via import settings) doesn't seem to fix this. What files should be included in order to import the right variables?
thanks!