Import Error on Django app - django

I'm getting the following error message:
ImportError at /youtube_submit
No module named util.process
Request Method: GET
Request URL: http://myapp.com:8000/youtube_submit?videoid=vSlF8EFo8QA
Django Version: 1.4.1
Exception Type: ImportError
Exception Value:
No module named util.process
Exception Location: /Users/filipeximenes/Projects/trainee/trainee/views/youtube_submit.py in <module>, line 6
Python Executable: /Users/filipeximenes/Projects/trainee/venv/bin/python
Python Version: 2.7.3
Python Path:
['/Users/filipeximenes/Projects/trainee',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/site-packages/distribute-0.6.27-py2.7.egg',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/site-packages/pip-1.1-py2.7.egg',
'/Users/filipeximenes/Projects/trainee/venv/lib/python27.zip',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/plat-darwin',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/plat-mac',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/lib-tk',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/lib-old',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/lib-dynload',
'/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/site-packages']
This is my requirements file:
Django==1.4.1
South==0.7.6
amqplib==1.0.2
anyjson==0.3.3
billiard==2.7.3.12
celery==3.0.9
distribute==0.6.27
dj-database-url==0.2.1
django-celery==3.0.9
facebook-sdk==0.3.2
gdata==2.0.17
gunicorn==0.14.6
kombu==2.4.5
psycopg2==2.4.5
python-dateutil==1.5
python-openid==2.2.5
wsgiref==0.1.2
I'm running the app locally, and I do have __init__.py files in all my modules.
And the app is installed:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'main',
'trainee',
'company',
'videos',
'south',
)
I have other apps working perfectly, the only one that is giving me pain is the videosone.
Any ideas on whats the problem?
EDIT:
youtube submit imports:
from videos.util.process import verify_video
process.py imports:
from videos.util.youtube import YoutubeUtil
youtube.py imports:
import gdata.youtube.service
import urlparse
from videos.util.verifier import Verifier
verifier.py doesn't import anything
EDIT:
I created another app and copied all files to it.
I magically started working.

In /youtube_submit view of videos application you have imported something like this,
from util.process import *
And since ther's no such module or the folder process has no __init__.py file, you get this error

I created another app and copied all files to it. Somehow it's working now.

Related

The main application of my website is not viewed when running it

I am not able to launch my website. It is showing the bellow error when running it iPlanetHoster.
ModuleNotFoundError at /home/massvnrc/myproject/myproject/myapp/templates/index.html
No module named '/myapp'
Request Method: GET
Request URL: ***/home/massvnrc/myproject/myproject/myapp/templates/index.html
Django Version: 1.9.13
Exception Type: ModuleNotFoundError
Exception Value:
No module named '/myapp'
Exception Location: /home/massvnrc/virtualenv/myproject/3.7/lib64/python3.7/importlib/__init__.py in import_module, line 127
Python Executable: /home/massvnrc/virtualenv/myproject/3.7/bin/python3.7_bin
Python Version: 3.7.3
Python Path:
['/home/massvnrc/myproject',
'/opt/passenger-5.3.7-9.el7.cloudlinux/src/helper-scripts',
'/home/massvnrc/virtualenv/myproject/3.7/lib64/python37.zip',
'/home/massvnrc/virtualenv/myproject/3.7/lib64/python3.7',
'/home/massvnrc/virtualenv/myproject/3.7/lib64/python3.7/lib-dynload',
'/opt/alt/python37/lib64/python3.7',
'/opt/alt/python37/lib/python3.7',
'/home/massvnrc/virtualenv/myproject/3.7/lib/python3.7/site-packages']
Server time: Thu, 23 Jan 2020 18:03:11 +0000
Here are some pictures that are showing where my files are located.
enter image description here
Can somebody tell me why I am getting this erro
You deployed the website with debug mode turned on - never do this, at least without restricting access.
Anyway, because of this I was able to see your urls.py:
from django.contrib import admin
from django.conf.urls import url, include
# from .import views
from django.contrib.auth import views as auth_views
urlpatterns = [
url('admin/', admin.site.urls),
url('', include('/myapp.urls')), ...
]
And installed apps from settings:
INSTALLED_APPS
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
I do not see myapp registered in settings. You need to add it.
Next is that include('/myapp.urls') should be changes to include('myapp.urls')

Pyforms web sample now working, only django's default site showing up

I'm trying to follow along with the example shown here: https://pyforms-web.readthedocs.io/en/v4/getting-started/first-app.html to get the first app running.
The Directory Structure of the default Django app looks like that.
I added the code as in the example, ran migrate and opened the brower, but only the default Django page shows up.
My site_crawl.py looks like this:
from pyforms.basewidget import BaseWidget
from confapp import conf
class SiteCrawlApp(BaseWidget):
UID = 'site-crawl-app'
TITLE = 'Site crawl'
LAYOUT_POSITION = conf.ORQUESTRA_HOME
ORQUESTRA_MENU = 'left'
ORQUESTRA_MENU_ICON = 'browser'
ORQUESTRA_MENU_ORDER = 0
The settings.py looks like:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'project',
]
Those are the only changes I made to the default structure created when I ran django-admin startproject project also ran python manage.py migrate before starting the web server with python manage.py runserver.
I'm using Python 3.6.0, Django 2.1.7 and Pyforms v4.
Can somebody help me figure out what I'm doing wrong? Thanks!

'bootstrap3' is not a valid tag library: ImportError raised loading bootstrap3.templatetags.bootstrap3: cannot import name force_text

I am going through tutorials on django-bootstrap by this link : "https://pypi.python.org/pypi/django-bootstrap3https://pypi.python.org/pypi/django-bootstrap3"
in my settings.py:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
'example_app',
'southtut',
'south',
'bootstrap3',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
in my templates:
i have written
{% load bootstrap3 %}
but i am getting the follwoing on the above mentioned line in templates like:
TemplateSyntaxError at /myapp/product/
'bootstrap3' is not a valid tag library: ImportError raised loading bootstrap3.templatetags.bootstrap3: cannot import name force_text
Request Method: GET
Request URL: http://127.0.0.1:8000/myapp/product/
Django Version: 1.4.1
Exception Type: TemplateSyntaxError
Exception Value:
'bootstrap3' is not a valid tag library: ImportError raised loading bootstrap3.templatetags.bootstrap3: cannot import name force_text
Exception Location: C:\Python27\lib\site-packages\django\template\defaulttags.py in load, line 1043
Python Executable: C:\Python27\python.exe
Python Version: 2.7.1
Python Path:
['C:\\Users\\Gopi\\workspace\\myfirst',
'C:\\Python27\\lib\\site-packages\\geraldo-0.4.16-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\configparser-3.2.0r3-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\unittest2-0.5.1-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\ordereddict-1.1-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\passlib-1.6.1-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\south-0.8.3-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\openpyxl-1.7.0-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\xlutils-1.7.0-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\tesseracttrainer-0.1.1-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\goslate-1.1.2-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\futures-2.1.6-py2.7.egg',
'C:\\Windows\\system32\\python27.zip',
'C:\\Python27\\DLLs',
'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win',
'C:\\Python27\\lib\\lib-tk',
'C:\\Python27',
'C:\\Python27\\lib\\site-packages',
'C:\\Python27\\lib\\site-packages\\PIL',
'C:\\Python27\\lib\\site-packages\\win32',
'C:\\Python27\\lib\\site-packages\\win32\\lib',
'C:\\Python27\\lib\\site-packages\\Pythonwin',
'C:\\Python27\\lib\\site-packages\\wx-2.8-msw-unicode']
Server time: Mon, 3 Mar 2014 16:18:18 +0530
I don't know where i was wrong. help me please
The error here is "cannot import name force_text" and this is because you use Django 1.4

Upgrading Django 1.1.1 to 1.3.1, admin.autodiscover() raises exception asking for contenttypes

I switched a 1.1.1 Django project to 1.3.1. Upon calling admin.autodiscover() in urls.py, an exception is raised from sites.py in the admin framework stating:
ImproperlyConfigured at /
Put 'django.contrib.contenttypes' in your INSTALLED_APPS setting in order
to use the admin application
In settings.py, I have:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'my.app'
)
Things I checked:
The contenttypes framework is indeed in my INSTALLED_APPS setting.
I have not repeated my INSTALLED_APPS declaration anywhere else
The contenttypes entry in INSTALLED_APPS is listed before the admin entry.
Running django-admin.py shell and importing "django.contrib.contenttypes" works.
If I go to the offending lines in the admin (Django-1.3.1/django/contrib/admin/sites.py in check_dependencies, line 164), I see:
if not ContentType._meta.installed:
raise ImproperlyConfigured(...)
If I comment out the check, I can run my project and the admin works. I'm not sure how the _meta.installed property is supposed to be set on model types, so I am at a loss for what to do next.
I should also note that this same Django 1.3.1 installation is working with other projects using similar settings files.
Any hints or resources would be appreciated! Thanks!
django.contrib.contenttypes includes two models, ContentType and ContentTypeManager. My guess is that you haven't run manage.py syncdb after adding django.contrib.contenttypes to your INSTALLED_APPS.
This would make the if not ContentType._meta.installed check understandable: the ContentType model isn't available in the database yet.

ImportError admin module

I want to enter to administration application of my site.
on request: http://mysite.ru/admin/ - i get an error:
ImportError at /admin/
No module named admin.site.urls
Request Method: GET
Request URL: http://mysite.ru/admin/
Django Version: 1.2.1
Exception Type: ImportError
Exception Value:
No module named admin.site.urls
Exception Location: /usr/lib/python2.4/site-packages/django/utils/importlib.py in import_module, line 35
Python Executable: /usr/bin/python
Python Version: 2.4.3
Python Path: ['/home/z/sites', '/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg', '/usr/lib/python2.4/site-packages/MySQL_python-1.2.3-py2.4-linux-i686.egg', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages/Numeric', '/opt/CollabNet_Subversion/lib/svn-python', '/usr/lib/python2.4/site-packages/gtk-2.0']
Server time: Fri, 2 Jul 2010 02:19:12 -0500
Admin module i connected as it described here:
http://docs.djangoproject.com/en/1.2/intro/tutorial02/
What the problem?
You probably forgot to uncomment one of the lines in the settings.py:
For example:
Add "django.contrib.admin" to your
INSTALLED_APPS setting. Run python
manage.py syncdb. Since you have added
a new application to INSTALLED_APPS,
the database tables need to be
updated.
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin', #<---- !!!!! Uncomment
'mysite.polls'
)
And in your urls.py: (Although it looks like you've done this step already)
# Uncomment the next two lines to enable the admin:
from django.contrib import admin #<---- !!!!! Uncomment
admin.autodiscover() #<---- !!!!! Uncomment
urlpatterns = patterns('',
# Example:
# (r'^mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)), #<---- !!!!! Uncomment
)