Sublime Forum

Cannot import modules?

#1

Good afternoon,
I’m attempting to import a module but I keep getting the error: source code string cannot contain null bytes.
The file i’m attempting to import is a basic Function taken from a study book.

My saved module: (saved as pizza.py in a folder with all my other code)
#module_1
def make_pizza(size, *toppings)
“”“Print the list of toppings that have been requested.”""
print(f"\nMaking a {size}-inch pizza with the following toppings")
for topping in toppings:
print(f"- {topping}")

and my import call: (saved as make_pizzas.py. Also saved to same folder)
import pizza
pizza.make_pizza(16, ‘pepperoni’)
pizza.make_pizza(32, ‘soda’, ‘chili’, ‘ceral’)

I have tried to change my build path using a third party python download file and still cant figure out what to do.

0 Likes

#2

Where are you trying to import this? Inside of Sublime Text’s console or inside of python?

What is the errors you are getting?

Also, missing a semi-colon

def make_pizza(size, *toppings):
print(f"\nMaking a {size}-inch pizza with the following toppings")
for topping in toppings:
    print(f"- {topping}")
0 Likes

#3

Im trying to import into sublime text. The error i’m getting is source code string cannot contain null bytes. When I hit build. I double checked my code and the missing semi-colon was a copy error into this thread.

0 Likes

#5

I’ve solved it. Thank you for the assistance. The original import file was not functioning properly. making a new one and correctly calling the import fixed it.

1 Like