How to uninstall django-rest-swagger? - python

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

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.

Related

Import "rest_framework_swagger.views" could not be resolved

I wanted to implement swagger in Django rest framework, for that I install django-rest-swagger and register in setting.py but while importing in url.py it show error:-
"Import "rest_framework_swagger.views" could not be resolved.
How can I use rest_framework_swagger?
You should be calling this way.
Example :
from rest_framework_swagger.views import get_swagger_view
Instead of get_swagger_view call the view you require.
There could be many reasons but the truth is you shouldn't be using a project that's read-only for over 2.5 years.
Try drf-yasg or drf-spectacular instead.
Anyway, if you installed the lib you're talking about with
pip install django-rest-swagger
it should be available in your environment. Make sure you see it in pip freeze.

Error in template flask run AndreiD/Flask-Easy-Template

Good Morning!
I am a beginner in the python / flask world ... I found this template and found it complete and simple, good for beginners and with some interesting features.
I just can not run this template. It has some packages that do not install by pip (pycrypto==2.6.1, python-cloudfiles==1.7.11, python-loaders==0.2.3).
Was this a reason? Can anybody help me?
I need some help to run this template.
enter image description here
Thanks!
This project is unmaintained, please try this one instead.
For your question, flask.ext.foo is the old way to import extension and it is removed in Flask 1.0. If you want to fix it, try the methods below:
Method 1: Fix old import statements
Find these lines in application/__init__.py:
from flask.ext.cache import Cache
from flask.ext.sqlalchemy import SQLAlchemy
change them to:
from flask.cache import Cache
from flask.sqlalchemy import SQLAlchemy
Method 2: Use a virtual enviroment
Everything will be ok if you use the pinned version in the project's requirement file. Just create a virtual enviroment with virtualenv, pipenv, poetry, venv etc, activate the virtual enviroment, then install dependency from the requirements.txt file.

setting up Django for internal web server ( from window to linux ) , what exactly do I need to install ?

I'm the beginner. I'm trying to deploy Django app to the internal web-server that is control by admin. The apache linux box with python 2.6 installed , but I am using 2.7 - on windows - other than following settings from http://www.djangobook.com/en/2.0/chapter12.html
My question is , what are the installations that I have to ask the admin to install in the linux box ?
Install Django following https://docs.djangoproject.com/en/dev/topics/install/
?
Python version : remove 2.6 and replaced with 2.7 python ? <- does it necessary ?
What about all the
packages ? For example I use pandas. I usually do
"pip install
pandas"
on my windows, do I need to ask admin to install that as well ?
If I don't use Django , but normal html - I usually just FTP to
/virtualhosts/mycompany.com/reports/www/index.html
and I would be able to see it. For Django I have >
mysite1/
manage.py
mysite2/
__init__.py
settings.py
urls.py
wsgi.py
Do i upload all mysite1 to replace index.html ( /virtualhosts/mycompany.com/reports/www/ ) ?
Sorry i am truly beginner here.
You should ask admin to install virtualenv so you will be able to install everything else on your own.
Anyway you will have to get ssh access to server to be able run your projects, so ask admin for it.
To install Django you just pip install django and you will get latest version
Python 2.7 is not necessary, but desirable since you might face problems on 2.6 like some modules you install might not be supported by 2.6 version
If you've followed official tutorial, yu should have been created requirements.txt in your projects, just find this file and send it to your admin, asking him to pip install -r requirments.txt. If not - you should read about this file cause it kind of must-have in project.
FTP upload - yes, you have to upload whole folder mysite1
I recommend you check out this thing, cause it is very easy and useful, especially if admin will help you to install it virtualenv wrapper
Edit: also consider installing Ubuntu alongside with Windows(it has such option out-of-box) You will fall in love with it for sure and will not be willing to return on Windows(except to play games if you do)

how to install django-scheduler in my project. I am getting an error saying module cannot be imported

I am trying to add the django package know as Django-scheduler in to my project. Please walk me through it by steps as how I have to install it and then run in my project.
Thanks in advance.
I am one of the contributors of the django-scheduler project
for install django scheduler on your env please ejecute the following steps:
pip instal django-scheduler
add to your django settings.py the scheduler app (watch out the "r" on project name here!):
INSTALLED_APPS += ('schedule',)
I just noticed that you need to put as installed app "schedule" instead of "scheduler" (this is going to be fixed in next version.
add to TEMPLATE_CONTEXT_PROCESSORS:
"django.core.context_processors.request"
then sync your db with:
python manage.py syncdb
please provide an example of how you are using the django-scheduler or how you are importing it (I will edit this answer asap).

Django docutils not working

I'm trying to enable docutils for django on windows 7. I've enabled the links in urls.y and settings.py and downloaded and installed the latest snapshot of docutils. However every time I try to access the documentation link in the admin I get a page asking me to install docutils.
Any ideas?
Thanks
I guess django tries to do
import docutils
And this fails. Django catches the exception and displayes this message to you.
Please try to get the real exception. You could insert the above line in one of your views:
def myview(request, ...):
import docutils
I hope django shows you the ImportError. Post it here, if still can't fix it.
Did you restart the Django server? Django has to restart to recognize the newly installed admindocs.
any chance you missed importing the admin in the urls.py?
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
You might have installed the docutils module in the virtual env/path.
Uninstall it from the virtual path and re-install it in the global python installation folder. That should solve the problem.
Note: Do not install django-docutils, but just simply docutils

Categories

Resources