0

I found this question helpful, but Python is unable still to find the folder.

I have a Django folder structure that looks like this:

  • todoproject
    • pythonDiscordChatbot
      • processLessons.py
    • todoapp
      • testChatFunctions.py

I'm trying to import a function called 'routes' into testChatFunctions.py, but I keep getting this error:

 File "c:\Users\Kaij\Documents\chatSiteDjango\todoproject\todoapp\testChatFunctions.py", line 6, in <module>tSiteDjango\todoproject\todoapp\tesssLesson import *tChatFunctions.py", line 6, in <modd 'pythonDiscordChatbot'ule>                               atSiteDjango> & C:/Users/Kaij/Documents/djangoTests/django_tailwind_project/env/Scripts/
    from pythonDiscordChatbot.procechatSiteDjango/todoproject/todoapp/testChatFunctions.pyssLesson import *
ModuleNotFoundError: No module nametSiteDjango\todoproject\todoapp\testChatFunctions.py", line 6, in <module>d 'pythonDiscordChatbot

Here's what I have tried:

# Bring your packages onto the path
import sys, os
sys.path.append(os.path.abspath(os.path.join('..', 'pythonDiscordChatbot')))

# Now do your import
from pythonDiscordChatbot.processLesson import *

# from pythonDiscordChatbot.processLesson import routes
routes("hello", "website_180.02.1")
halfer
  • 19,824
  • 17
  • 99
  • 186
Katie Melosto
  • 1,047
  • 2
  • 14
  • 35
  • 1
    have you tried adding `__init__.py` file in the `pythonDiscordChatbot` folder? – KostisPar Nov 19 '21 at 13:55
  • I really don't think you should need to add an __init__.py file. Also, is the error actually coming out exactly like that? Because it seems odd to have what looks like 2 separate strings randomly jumbled together like that. – Cmd858 Nov 19 '21 at 14:05

0 Answers0