Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Installation fails if the Django project root isn't in the PYTHONPATH #5

Closed
yprez opened this issue Jul 21, 2013 · 2 comments
Closed

Comments

@yprez
Copy link

yprez commented Jul 21, 2013

django-rest-swagger tries to import settings on installation and fails if the setting file isn't in the path.

$ pip install django-rest-swagger
Downloading/unpacking django-rest-swagger
  Running setup.py egg_info for package django-rest-swagger
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "[VIRTUALENV_PATH]/build/django-rest-swagger/setup.py", line 3, in <module>
        from rest_framework_swagger import VERSION
      File "rest_framework_swagger/__init__.py", line 14, in <module>
        SWAGGER_SETTINGS = getattr(settings, 'SWAGGER_SETTINGS', DEFAULT_SWAGGER_SETTINGS)
      File "[VIRTUALENV_PATH]/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
        self._setup(name)
      File "[VIRTUALENV_PATH]/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in _setup
        self._wrapped = Settings(settings_module)
      File "[VIRTUALENV_PATH]/lib/python2.7/site-packages/django/conf/__init__.py", line 134, in __init__
        raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
    ImportError: Could not import settings 'settings' (Is it on sys.path?): No module named settings
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "[VIRTUALENV_PATH]/build/django-rest-swagger/setup.py", line 3, in <module>

    from rest_framework_swagger import VERSION

  File "rest_framework_swagger/__init__.py", line 14, in <module>

    SWAGGER_SETTINGS = getattr(settings, 'SWAGGER_SETTINGS', DEFAULT_SWAGGER_SETTINGS)

  File "[VIRTUALENV_PATH]/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__

    self._setup(name)

  File "[VIRTUALENV_PATH]/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in _setup

    self._wrapped = Settings(settings_module)

  File "[VIRTUALENV_PATH]/lib/python2.7/site-packages/django/conf/__init__.py", line 134, in __init__

    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))

ImportError: Could not import settings 'settings' (Is it on sys.path?): No module named settings

Workaround: add the path where the project resides to the PYTHONPATH.

@marcgibbons
Copy link
Owner

Should be fixed now - the exception is happening when Django isn't available. Let me know if you still get exceptions. Many thanks!
2f634de

@yprez
Copy link
Author

yprez commented Jul 22, 2013

Many thanks!

lucasnad27 pushed a commit to lucasnad27/django-rest-swagger that referenced this issue May 31, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants