2

Is there a simple or elegant way to uninstall django-rest-swagger on Windows 10? I've recently started developing API's and creating documentation. I found a tutorial that used the django-rest-swagger app. After installing the app and doing more reading, I discovered that it was deprecated, and the developer's GitHub page recommends using drf-yasg.

I tried using "pip uninstall django-rest-swagger," and that echoed back that the app was uninstalled. But, when I went into the virtual environment folder of the project, all the package folders were still there. I also tried "pipenv uninstall django-rest-swagger", but it returned "pipenv is not recognized..." I spent a few hours reading the app docs, and googling "how to remove/ uninstall django-rest-swagger." However, I didn't find anything useful.

Eventually, I gave up, and decided to do it the hard way. I manually deleted all the installed files. Fortunately, I hadn't updated my requirements.txt, so, I knew what was originally installed. While this solution worked, it was somewhat time consuming.

Does django-rest-swagger have an internal uninstall command? And does anyone know why "pip uninstall" didn't remove the app folders?

Thanks

Rice Man
  • 415
  • 1
  • 5
  • 16
  • I had the same problem when trying to uninstall directly from python. I managed to uninstall with 'pip uninstall django-rest-swagger' in the bash from the environment where it was installed. Hope that helps for linux users, I 'll see what I get on windows. – DvdG Aug 31 '21 at 17:53

1 Answers1

1

Just enable your virtualenv probably doing:

. /path/to/virtualenv/bin/activate

Then:

pip uninstall django-rest-swagger

Then go to settings.py and remove or comment the following line:

INSTALLED_APPS = [
    ...
    #'rest_framework_swagger',
    ...
]

And finally remove or comment in views.py the import and code related with swagger library:


from django.conf.urls import url
#from rest_framework_swagger.views import get_swagger_view

#schema_view = get_swagger_view(title='Pastebin API')

urlpatterns = [
#    url(r'^$', schema_view),
     ...
]

That's it.

allexiusw
  • 1,533
  • 2
  • 16
  • 23
  • Thank you for your answer. I see that your virtualenv activation script is in a Linux style pattern. I'm currently using a Windows 10 OS. However, when I ran the "pip uninstall django-rest-swagger" command, my virtual environment was activated, and I was in it. The command echoed back that DRS was removed, but after running "pip freeze", it showed that all the packages were still there. – Rice Man Aug 31 '21 at 19:43
  • Can something like enable verbose info in Powershell help you to figure out what's wrong with pip uninstall? https://stackoverflow.com/questions/41324882/how-to-run-a-powershell-script-with-verbose-output I'm not good at powershell. – allexiusw Aug 31 '21 at 19:59
  • That's a good question. Unfortunately, you can't enter a virtual environment from Powershell. But, I might be able to do something similar from CMD. I'll try to give that a go. – Rice Man Sep 01 '21 at 05:39
  • Yes you can activate a virtualenv in powershell, take a look of this thread: https://stackoverflow.com/questions/1365081/virtualenv-in-powershell – allexiusw Sep 01 '21 at 16:50
  • After doing some more reading and revisiting the code, I've decided to assume my problem was unique to my system and probably just a one-off. @allexiusw answer is correct and, under normal circumstances, it should always work. Many thanks to him and everyone else that looked into this problem. – Rice Man Oct 18 '21 at 22:47