ModuleNotFoundError: No module named 'xxx.urls'

I’ve created an app just for my own use. I developed on my Windows machine and tested with the dblite database just fine. I have a Linux server I want to run this on with MySQL. I updated the db to MySql running on the server and pointed to that. All worked fine. I then set up my Django framework on the server. After fighting with getting the python working (I’m running OpenSuse), I was able to use runserver to validate the code works. All is good there. Now working to get the Apache server correct. Ugh. I get an error ModuleNotFoundError: No module named ‘budget.urls’. Budget is my app. I’ve tried all kinds of things. I had set up a different project on AWS just fine and replicated my configuration from there (other than that being Ubuntu so the http config was in a different file) I’m sure it is just something stupid I cannot see so but looking for insight. I hope the following snippets help:

settings.py:

INSTALLED_APPS = [
    'budget',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

urls.py (from project folder):

from django.contrib import admin
from django.urls import path 
from django.urls import re_path
from django.urls import include

urlpatterns = [
    re_path('budget/', include('budget.urls')),
    re_path('admin/', admin.site.urls),
]

httpd.conf:

WSGIDaemonProcess budget python-home=/home/mervine/budget-env python-path=/home/mervine/budget
WSGIProcessGroup budget
WSGIScriptAlias / /home/mervine/merfinance/MerFinance/wsgi.py


<Directory /home/mervine/merfinance/MerFinance>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

Thanks in advance.
(I originally used path in the urls file and changed to re_path based on some research; no difference)

Side note: When posting code here, enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted. (I’ve taken the liberty of modifying your original post to fix this.)

It’s been a long time since I’ve had to configure an Apache server, but it seems to me that you’ve got the wrong “python-path” attribute defined here:

Based on the rest of your configuration, I think that part of the line should be python-path=/home/mervine/merfinance

This is assuming that /home/mervine/merfinance is the base directory for your project, and that your app (budget) is in that directory.

If that’s not the case, please explain how your project is organized by directory.

Thanks, Ken, for the tip on the format. And actually that item you caught was just my latest try. You are right on the correction (that was my original) I was just grasping at straws.

I finally figured out my problem (face palm here). My file permissions were not correct in my folder. When I did the FTP, it didn’t give enough permissions. I had original set the folder open but I guess when uploading the files, the permissions reverted. So at least this post is here for posterity and I still learned something from Ken.

1 Like