Fix - NameError: name 'Print' is not defined in Python


Borislav Hadzhiev

Wed Apr 20 20221 min read

Fix - NameError: name 'Print' is not defined in Python #

The Python "NameError: name 'Print' is not" occurs when we misspell the built-in print() function. To solve the error, make sure to spell print in all lowercase letters and don't declare a variable named print in your code.

nameerror name print is not defined

Here is an example of how the error occurs.
# ⛔️ NameError: name 'Print' is not defined. Did you mean: 'print'? Print('Hello world') # 👈️ spelled print() with capital P

To solve the error, we have to spell the print() function in all lowercase letters.
print('Hello world')

Names of variables, functions and classes are case-sensitive in Python, so the identifiers print and Print are completely different.

Make sure you haven't declared a variable named print in your code, e.g. print = 'something else'.

Re-declaring a variable that's associated with a built-in function can lead to some very confusing behavior.

Another thing to watch out for is to not name your modules using a reserved name, e.g. because that could shadow a module you are trying to import.

The print() function is always available in Python and does not require an import statement, so if spelled correctly (all lowercase letters), the error should be resolved.

Use the search field on my Home Page to filter through my more than 1,000 articles.