Reputation: 363
I wrote a simple Python program 'guessing_game.py'. When I try to run this code in the command prompt using python -m guessing_game.py
, the program runs fine, but in the end, it says:
Error while finding module specification for 'guessing_game.py'
(ModuleNotFoundError: path attribute not found on 'guessing_game' while trying to find 'guessing_game.py').
When I run the same program using python -guessing_game.py
, it runs fine, and it doesn't show that message as well.
Upvotes: 4
Views: 4128
Reputation: 80
Because you're trying to run it as a module?
From https://docs.python.org/3/using/cmdline.html#cmdoption-m
-m
<module-name>
Search sys.path for the named module and execute its contents as the
__main__
module.Since the argument is a module name, you must not give a file extension (.py). The module name should be a valid absolute Python module name, but the implementation may not always enforce this (e.g. it may allow you to use a name that includes a hyphen).
Upvotes: 4