I added django_haystack version to setup.py, deleted haystack-0.16-py2.7.egg folder in site-packages and it works. Dont know how I got old version there.
Module is not found on openshift in django app
-
11-06-2023 - |
Вопрос
I don't know how its possible, but my module can't be found. I wanted to integrate haystack to django app. When I pushed it to openshift, where I had specified 'django_haystack' in setup.py, it didn't work. So I copied haystack package from python dist to my django project.
.
├── controller
├── database
├── django_crontab
├── faq
├── haystack
├── lib
├── registration
├── stocks
└── whoosh
I added 'haystack' to installed_apps in settings.py. To make sure this package in my localhost works, I uninstalled django_haystack in python dist-packages through pip. On localhost it works. I'm trying to import haystack.forms to stocks.forms. I pushed new commit to openshift. I get error code 500 when I try to load my site. Error is:
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] ImportError: No module named forms
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] mod_wsgi (pid=262837): Exception occurred processing WSGI script '/var/lib/openshift/526ed6ba4382eca6ff000024/app-root/runtime/repo/wsgi/application'.
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] Traceback (most recent call last):
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] File "/var/lib/openshift/526ed6ba4382eca6ff000024/python/virtenv/lib/python2.7/site-packages/Django-1.5.5-py2.7.egg/django/core/handlers/wsgi.py", line 255, in __call__
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] response = self.get_response(request)
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] File "/var/lib/openshift/526ed6ba43826ff000024/python/virtenv/lib/python2.7/site-packages/Django-1.5.5-py2.7.egg/django/core/handlers/base.py", line 178, in get_response
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] File "/var/lib/openshift/526ed6ba43826ff000024/python/virtenv/lib/python2.7/site-packages/Django-1.5.5-py2.7.egg/django/core/handlers/base.py", line 220, in handle_uncaught_exception
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] if resolver.urlconf_module is None:
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] File "/var/lib/openshift/526ed6ba43826ff000024/python/virtenv/lib/python2.7/site-packages/Django-1.5.5-py2.7.egg/django/core/urlresolvers.py", line 342, in urlconf_module
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] self._urlconf_module = import_module(self.urlconf_name)
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] File "/var/lib/openshift/526ed6ba43826ff000024/python/virtenv/lib/python2.7/site-packages/Django-1.5.5-py2.7.egg/django/utils/importlib.py", line 35, in import_module
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] __import__(name)
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] File "/var/lib/openshift/526ed6ba43826ff000024/app-root/runtime/repo/wsgi/digrin/controller/urls.py", line 3, in <module>
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] from stocks.forms import AdvancedSearchForm, AutocompleteModelSearchForm
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] File "/var/lib/openshift/526ed6ba43826ff000024/app-root/runtime/repo/wsgi/digrin/stocks/forms.py", line 31, in <module>
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] from haystack.forms import ModelSearchForm
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] ImportError: No module named forms
ImportError: No module named forms
So it's basically first mention of haystack app. I logged into my openshift account with ssh and ran ./manage.py shell
where I tried from haystack.forms import ModelSearchForm
. It loaded without problems.
I am out of ideas here, I also tried ./manage.py syncdb
and ./manage.py migrate
in case haystack did miss some db tables. Also tried restarting app. Didn't help. What am I missing?
Ok, so I deleted folder haystack from my apps and added django_haystack to setup.py as instructed.
I looked what files are in my local server in haystack folder:
lucas03@Mirko:~$ ls /usr/local/lib/python2.7/dist-packages/haystack
admin.py constants.pyc fields.pyc indexes.pyc inputs.pyc models.py query.py signals.py urls.py views.pyc
admin.pyc exceptions.py forms.py __init__.py management models.pyc query.pyc signals.pyc urls.pyc
backends exceptions.pyc forms.pyc __init__.pyc manager.py panels.py routers.py templates utils
constants.py fields.py indexes.py inputs.py manager.pyc panels.pyc routers.pyc templatetags views.py
And this where manage.py points me to haystack.
>>> import haystack
>>> haystack
<module 'haystack' from '/var/lib/openshift/526ed6ba43826ff000024/python/virtenv/lib/python2.7/site-packages/haystack-0.16-py2.7.egg/haystack/__init__.pyc'>
>>>
and this is my openshift haystack contents:
ls /var/lib/openshift/526ed6ba43826ff000024/python/virtenv/lib/python2.7/site-packages/haystack-0.16-py2.7.egg/haystack/
abouchet.py basicmodel.pyc dump_loader.py listmodel.py memory_dumper.pyc model.py win-dump-heap.py
abouchet.pyc config.py dump_loader.pyc listmodel.pyc memory_mapper.py model.pyc win-dump-heap.pyc
argparse_utils.py config.pyc gui __main__.py memory_mapper.pyc reverse
argparse_utils.pyc dbg.py __init__.py __main__.pyc memory_mapping.py utils.py
basicmodel.py dbg.pyc __init__.pyc memory_dumper.py memory_mapping.pyc utils.pyc
These are my site packages: site-packages]> ls
argparse-1.2.1-py2.7.egg easy-install.pth pip setuptools
Digrin.egg-link easy_install.py pip-1.4-py2.7.egg-info setuptools-0.9.8-py2.7.egg-info
Django-1.5.5-py2.7.egg easy_install.pyc pkg_resources.py six-1.4.1-py2.7.egg
django_extensions-1.2.5-py2.7.egg haystack-0.16-py2.7.egg pkg_resources.pyc South-0.8.2-py2.7.egg
django_haystack-2.1.0-py2.7.egg _markerlib python_ptrace-0.7-py2.7.egg
Решение