Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

How to import your own modules into Python?

So I've made my own set of functions, but I don't want to keep them in one bug project. I find it messy. I put in my .py file (Let's call it func.py for now). But when I try to use func.py, I get this error:

C:\Users\Swaggy\AppData\Local\Programs\Python\Python35-32\python.exe C:/Users/Swaggy/PycharmProjects/ChatRooms/Court.py
Traceback (most recent call last):
  File "C:/Users/Swaggy/PycharmProjects/ChatRooms/Court.py", line 1, in <module>
    from court_functions import *
ImportError: No module named 'court_functions'

Any help would be great!

1 Answer

Your code looks fine.

  • Make sure your module is in the same folder/directory.
  • Make the name of the file (excluding the .py part) is the same as the name you are using to import the file.

If you are still experiencing errors, please reply :)

~Alex