LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-12-2021, 01:10 AM   #1
maschelsea
Member
 
Registered: Dec 2016
Distribution: Slackware 64bit 14.2
Posts: 467

Rep: Reputation: Disabled
Need help with old django: ImportError: No module named app


I'm taking yet another course at Skillshare. Skillshare seems to be a place to dump your programming courses. I doubt the teacher is actually available, otherwise I'd ask her.

My current issue (I suspect) is because I am using old Python (2.7.17) with an old Django (1.11.13) (version provided by the teacher in a download form) I have done what I'm trying to do in this course with other newer versions of Django (Django 2.x) But I'm having enormous difficulty finding any infomation on my particular error. When I took programming in college, it wasn't this hard. Nothing was. But then I didn't use it everyday for ten years. Then for ten years after that I didn't use it at all. It's rather ironic. I'm thinking of redoing my old COBOL final project in python. That is, in Python 3. But that's neither here nor there.

My issue is this:
Code:
michael@caitlyn Skeleton Project (django-admin) $ python manage.py runserver
Unhandled exception in thread started by <function wrapper at 0x7efc5297e6d0>
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/Django-1.11.13-py2.7.egg/django/utils/autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/Django-1.11.13-py2.7.egg/django/core/management/commands/runserver.py", line 116, in inner_run
    autoreload.raise_last_exception()
  File "/usr/lib64/python2.7/site-packages/Django-1.11.13-py2.7.egg/django/utils/autoreload.py", line 251, in raise_last_exception
    six.reraise(*_exception)
  File "/usr/lib64/python2.7/site-packages/Django-1.11.13-py2.7.egg/django/utils/autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/Django-1.11.13-py2.7.egg/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/lib64/python2.7/site-packages/Django-1.11.13-py2.7.egg/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/usr/lib64/python2.7/site-packages/Django-1.11.13-py2.7.egg/django/apps/config.py", line 120, in create
    mod = import_module(mod_path)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
ImportError: No module named app
One of my many Python teachers said that to be taken seriously as a programmer, I need to learn to look up the answers on StackOverflow and other such sites. I looked up this problem on StackOverflow and someone there was having a problem that seemed similar to mine said that I should create a file named app.py in the same directory that __init__.py is in, so I did. It didn't help. There IS no __init__.py. There's __init__pyc and __init__pyo, both of them binary files. With my app.py file, which I made with touch:
Code:
root@caitlyn:~# ls /usr/lib64/python2.7/importlib/           
__init__.pyc  __init__.pyo  app.py
root@caitlyn:~# file /usr/lib64/python2.7/importlib/__init__.pyc
/usr/lib64/python2.7/importlib/__init__.pyc: python 2.7 byte-compiled
root@caitlyn:~# file __init__.pyo
__init__.pyo: cannot open `__init__.pyo' (No such file or directory)
root@caitlyn:~# file /usr/lib64/python2.7/importlib/__init__.pyo
/usr/lib64/python2.7/importlib/__init__.pyo: python 2.7 byte-compiled
root@caitlyn:~#
Any help with resolving this issue will be appreciated. Thank you in advance for any advice you can offer.
 
Old 08-12-2021, 05:15 AM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 2,550

Rep: Reputation: Disabled
Could it be a typo somewhere in the script? Like app instead of apps? You probably have something like
Code:
from django.apps import apps
 
Old 08-12-2021, 10:27 AM   #3
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 1,618

Rep: Reputation: 1315Reputation: 1315Reputation: 1315Reputation: 1315Reputation: 1315Reputation: 1315Reputation: 1315Reputation: 1315Reputation: 1315Reputation: 1315
Quote:
Originally Posted by maschelsea View Post
I doubt the teacher is actually available, otherwise I'd ask her.
"Doubt"? You mean you can't be bothered to try.


Quote:
My issue is this:
Code:
michael@caitlyn Skeleton Project (django-admin) $ python manage.py runserver
<snip>
ImportError: No module named app
Python cannot find the "app" module. There are a number of potential reasons for this error.

The course teacher will know whether that module should exist (and where it should be), whether it should have been created earlier, etc - and thus can tell you very quickly whether it's a typo, path issue, or something else.

Without even a reference to the course, all anybody here can do is make guesses.



Quote:
One of my many Python teachers said that to be taken seriously as a programmer, I need to learn to look up the answers on Stack Overflow and other such sites.
Being able to search effectively is vital, but programmers who only look up answers on Stack Overflow are ones that aren't taken seriously.

Good programmers understand what errors are saying and will look for explanations not answers - those can come from many websites.

Generally the Stack Overflow responses worth considering are the ones that explain why the error is occurring and link to relevant documentation - i.e. those that assist with understanding - but a large number of them are written by mediocre programmers with a limited grasp on what they're responding to.


Quote:
I looked up this problem on StackOverflow and someone there was having a problem that seemed similar to mine said that I should create a file named app.py in the same directory that __init__.py is in, so I did. It didn't help. There IS no __init__.py. There's __init__pyc and __init__pyo, both of them binary files.
If you don't understand what __init__.py is and which directories it exists in, you should read the Python documentation on modules.

Once you have read that, you may understand why creating app.py in one of Python's system directories was never going to solve your problem (and is a misunderstanding of whatever the issue on StackOverflow was).


Last edited by boughtonp; 08-12-2021 at 10:28 AM.
 
Old 08-13-2021, 08:52 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,291
Blog Entries: 4

Rep: Reputation: 3318Reputation: 3318Reputation: 3318Reputation: 3318Reputation: 3318Reputation: 3318Reputation: 3318Reputation: 3318Reputation: 3318Reputation: 3318Reputation: 3318
Carefully read the Django documentation on modules. Yes, it might be a tpyo!
 
Old 08-16-2021, 12:43 AM   #5
maschelsea
Member
 
Registered: Dec 2016
Distribution: Slackware 64bit 14.2
Posts: 467

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by shruggy View Post
Could it be a typo somewhere in the script? Like app instead of apps? You probably have something like
Code:
from django.apps import apps
You were right. In my <root>/settings.py it said to import jobs.app.JobListing. I changed it from app to apps and it started up. Thank you for your help!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gDesklets - ImportError: No module named gnome.ui raffi Linux - Software 9 10-20-2005 12:48 PM
Bittorrent. "ImportError: No module named __future__" BashTin Linux - Software 4 09-12-2005 03:07 AM
iPodder: ImportError: No module named wx dr_zayus69 Linux - Software 6 07-06-2005 01:55 AM
ImportError: No module named libglade Kanaflloric Programming 0 08-16-2004 09:58 PM
ImportError: No module named gconf linorg Linux - Software 8 02-02-2004 04:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration