Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors in 0.8.1 when run with Django/uWSGI, but not with Django's dev runserver #1741

Closed
danxshap opened this issue Aug 7, 2012 · 3 comments
Labels
Milestone

Comments

@danxshap
Copy link
Contributor

danxshap commented Aug 7, 2012

I'm using pandas in a Django application running on Ubuntu 12.04 and after upgrading from pandas 0.6.1 to 0.8.1 I'm getting some errors that completely prevent the application from running.

If I run Django's development server (manage.py runserver), everything works fine, but if instead I run uWSGI I see the following 2 tracebacks in my uwsgi log:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 101, in get_response
    request.path_info)
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 298, in resolve
    for pattern in self.url_patterns:
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 328, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 323, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/sites/ycharts/urls.py", line 5, in <module>
    from apps.companies.sitemaps import CompanySitemap
  File "/sites/ycharts/apps/companies/sitemaps.py", line 6, in <module>
    from apps.companies.models import Company
  File "/sites/ycharts/apps/companies/models.py", line 19, in <module>
    from apps.main.utils import googlesearch, wikipedia, date_utils, data_utils, \
  File "/sites/ycharts/apps/main/utils/data_utils.py", line 3, in <module>
    import pandas
  File "/usr/local/lib/python2.7/dist-packages/pandas/__init__.py", line 14, in <module>
    import pandas.lib as lib
AttributeError: 'module' object has no attribute 'lib'

and

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 101, in get_response
    request.path_info)
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 298, in resolve
    for pattern in self.url_patterns:
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 328, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 323, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/sites/ycharts/urls.py", line 5, in <module>
    from apps.companies.sitemaps import CompanySitemap
  File "/sites/ycharts/apps/companies/sitemaps.py", line 6, in <module>
    from apps.companies.models import Company
  File "/sites/ycharts/apps/companies/models.py", line 19, in <module>
    from apps.main.utils import googlesearch, wikipedia, date_utils, data_utils, \
  File "/sites/ycharts/apps/main/utils/data_utils.py", line 3, in <module>
    import pandas
  File "/usr/local/lib/python2.7/dist-packages/pandas/__init__.py", line 28, in <module>
    from pandas.core.api import *
  File "/usr/local/lib/python2.7/dist-packages/pandas/core/api.py", line 10, in <module>
    from pandas.core.format import (set_printoptions, reset_printoptions,
  File "/usr/local/lib/python2.7/dist-packages/pandas/core/format.py", line 147, in <module>
    class DataFrameFormatter(object):
  File "/usr/local/lib/python2.7/dist-packages/pandas/core/format.py", line 156, in DataFrameFormatter
    __doc__ += docstring_to_string
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str

After reading in #284, I thought it may be a path issue so I tried overwriting sys.path in my uwsgi configuration file so that it's the exact same path that the dev server sets up for me, but that didn't help.

Any tips / debugging ideas / help on the above would be greatly appreciated.

Thank you!

@unbit
Copy link

unbit commented Aug 11, 2012

run the uWSGI pyshell and try importing the modules manually to find where the problem is (could be a loading order mess, a circular dependancies...). The main reason for such kind of problems is described here: http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html

@danxshap
Copy link
Contributor Author

Thanks @unbit for all the help in IRC with this!

Turns out that the errors only happen when using the uWSGI --optimize 2 which is the -OO python interpreter option which removes docstrings.

My fix for this is in #1792.

@wesm
Copy link
Member

wesm commented Sep 8, 2012

Thanks for the PR. Closing the issue

@wesm wesm closed this as completed Sep 8, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants