0

I'm following the book "Learn Python The Hard Way". For some reason I'm unable to import one python file into another. The error always says "No module named 'xxx'". Both files are in the same folder. I have tried doing it with Python 2.6 and 3.8 with both Powershell and Jupyter Notebook. Nothing is working. This is a very simple code. I am unable to understand why it isn't working. Totally stuck for days. Need help.

import prac6

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-10-8af45a888d19> in <module>
----> 1 from prac6 import break_words

ModuleNotFoundError: No module named 'prac6'
  • the name of the other file must be prac6.py for the import to work – JoKing Jun 15 '20 at 19:27
  • Does this answer your question? [How to import python file(.py) into a main python file](https://stackoverflow.com/questions/44491442/how-to-import-python-file-py-into-a-main-python-file) & [How to import other Python files?](https://stackoverflow.com/questions/2349991/how-to-import-other-python-files) – Trenton McKinney Jun 15 '20 at 19:32
  • Thanks I renamed the file from prac6 to prac6.py and it finally worked. – Zeba Lodhi Jun 15 '20 at 20:00

0 Answers0