Python Forum
importing module - not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
importing module - not working
#1
Hi all -
Total Python beginner looking for some help. I looked all over for an answer with no luck... sorry for the total newbie question. I'm working my way through Eric Matthes' Python Crash Course book.

Here's my code:
import pizza

pizza.make_pizza(16,'mushrooms')
Here is the file pizza - which is in the same directory as making.pizza
def make_pizza(size, *toppings):
	""" Summarize the pizza we are about to make """
	print(f"\nMaking a {size}-inch pizza with the following toppings:")
	for topping in toppings:
		print(f"- {topping}")
For some reason the import isn't working. Here's the error I'm getting...
Error:
Traceback (most recent call last): File "/Users/jdhamblett/Desktop/python_work/making_pizzas", line 1, in <module> import pizza ModuleNotFoundError: No module named 'pizza' [Finished in 0.4s with exit code 1] [cmd: ['python3', '-u', '/Users/jdhamblett/Desktop/python_work/making_pizzas']] [dir: /Users/jdhamblett/Desktop/python_work] [path: /Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin]
Is there a configuration setting I'm missing in Sublime Text (I couldn't get this to work on my terminal session either on my Mac). I'm running Python3 3.8.3.

Thanks for the help!
Reply
#2
I'm not familiar with sublime but, maybe the path is not included with sublime. Check your paths. Check to see if will work in a shell.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
Your files don't seem to have the extension .py, this is probably the cause of the error. Rename the files pizza.py and making_pizzas.py
Reply
#4
(Jun-22-2020, 07:29 PM)Gribouillis Wrote: Your files don't seem to have the extension .py, this is probably the cause of the error. Rename the files pizza.py and making_pizzas.py

I'm an idiot... that was exactly it... I was assuming Sublime was saving everything with the .py extension.

Ugh... thanks for the help... really appreciate it.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  importing variables from module 8376459 1 245 Feb-18-2024, 02:24 PM
Last Post: deanhystad
  no module named 'docx' when importing docx MaartenRo 1 705 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  working with TLV module Object Jennifer_Jone 3 1,075 Mar-14-2023, 07:54 PM
Last Post: Jennifer_Jone
  Unsure why module is not working garynewport 0 735 Feb-15-2023, 03:21 PM
Last Post: garynewport
  My code displays too much output when importing class from a module lil_e 4 1,102 Oct-22-2022, 12:56 AM
Last Post: Larz60+
  Pandas module not working Hass 2 1,669 Apr-14-2022, 03:13 PM
Last Post: snippsat
  Importing module in jupyter Noteboook ajitnayak1987 0 1,725 Jun-04-2021, 12:26 PM
Last Post: ajitnayak1987
  ERROR: importing desired module mbgamer28 0 1,648 Apr-05-2021, 07:46 PM
Last Post: mbgamer28
  importing same python library in multiple custom module escape_freedom13 6 3,723 May-10-2020, 07:01 PM
Last Post: escape_freedom13
  Importing module from a package results in import error goghvv 2 2,340 Mar-27-2020, 07:13 PM
Last Post: goghvv

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020