Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django-rest-framework + swagger ui: ImportError: No module named rest_framework_swagger

I'm trying to add django-rest-swagger ui to my api, but I'm getting ImportError: No module named rest_framework_swagger even though I've already done pip install django-rest-swagger. I can also see the package installed on my virtualenv through pip list. I've tried python manage.py syncdb as well but doesn't really do anything. Anyone have some suggestions for me? Thanks.

INSTALLED_APPS = (
'rest_framework',
'at_api',
'rest_framework_swagger',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)

EDIT: Sys path info

>>> import sys
>>> for p in sys.path: print p
...

C:\Users\Andrew\.virtualenvs\adventure_time\lib\site-packages\psycopg2-2.5.3-py2.7-win-amd64.egg
C:\Users\Andrew\.virtualenvs\adventure_time\lib\site-packages\six-1.8.0-py2.7.egg
C:\Users\Andrew\.virtualenvs\adventure_time\lib\site-packages\cssselect-0.9.1-py2.7.egg
C:\Users\Andrew\.virtualenvs\adventure_time\lib\site-packages\pyopenssl-0.14-py2.7.egg
C:\Users\Andrew\.virtualenvs\adventure_time\lib\site-packages\lxml-3.4.1-py2.7-win-amd64.egg
C:\Users\Andrew\.virtualenvs\adventure_time\lib\site-packages\queuelib-1.2.2-py2.7.egg
C:\Users\Andrew\.virtualenvs\adventure_time\lib\site-packages\w3lib-1.10.0-py2.7.egg
C:\Users\Andrew\.virtualenvs\adventure_time\lib\site-packages\twisted-14.0.2-py2.7-win-amd64.egg
C:\Users\Andrew\.virtualenvs\adventure_time\lib\site-packages\zope.interface-4.1.1-py2.7-win-amd64.egg
C:\Users\Andrew\.virtualenvs\adventure_time\lib\site-packages\zipline-0.7.0-py2.7.egg
C:\Users\Andrew\.virtualenvs\adventure_time\lib\site-packages\pandas-0.15.1-py2.7-win-amd64.egg
C:\Users\Andrew\.virtualenvs\adventure_time\lib\site-packages\pywin32-214-py2.7-win-amd64.egg
C:\Users\Andrew\.virtualenvs\adventure_time\lib\site-packages\pyyaml-3.11-py2.7-win-amd64.egg
C:\windows\system32\python27.zip
C:\Users\Andrew\.virtualenvs\adventure_time\DLLs
C:\Users\Andrew\.virtualenvs\adventure_time\lib
C:\Users\Andrew\.virtualenvs\adventure_time\lib\plat-win
C:\Users\Andrew\.virtualenvs\adventure_time\lib\lib-tk
C:\Users\Andrew\.virtualenvs\adventure_time\Scripts
C:\Python27\Lib
C:\Python27\DLLs
C:\Python27\Lib\lib-tk
C:\Users\Andrew\.virtualenvs\adventure_time
C:\Users\Andrew\.virtualenvs\adventure_time\lib\site-packages
>>>

Traceback:

Traceback (most recent call last):
  File "C:/Users/Andrew/Desktop/rocketu/adventure_time/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 280, in execute
    translation.activate('en-us')
  File "C:\Python27\lib\site-packages\django\utils\translation\__init__.py", line 130, in activate
    return _trans.activate(language)
  File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 188, in activate
    _active.value = translation(language)
  File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 177, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 159, in _fetch
    app = import_module(appname)
  File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 40, in import_module
    __import__(name)
ImportError: No module named rest_framework_swagger

Process finished with exit code 1
like image 754
pyramidface Avatar asked Jan 10 '23 07:01

pyramidface


1 Answers

Follow these steps to solve:

1- Make sure your Virtual Environment is activated.

2- install requirements or rest_framework_swagger using pip

    pip install django-rest-swagger

3- in File-> Settings -> Project Interpreter -> : select virtual environment for your project
4- in toolbar -> Edit configurations...-> python Interpreter : select your project virtual environment

like image 125
Hamed Jaliliani Avatar answered Jan 16 '23 20:01

Hamed Jaliliani