According to the python doc the -m
flag should do the following:
Search sys.path for the named module and execute its contents as the
__main__
module.
When I run my script simply with the python
command, everything works fine. Since I now want to import something from a higher level, I have to run the script with python -m
. However the __name__ == "__main__"
statement seems to return False
and the following Error is produced:
/home/<name>/anaconda3/bin/python: Error while finding module specification for 'data.generate_dummies.py' (AttributeError: module 'data.generate_dummies' has no attribute '__path__')
I dont't understand what the __path__
attribute has to do with that.
The error you get occurs when python tries to look for a package/module that does not exist. As user2357112 mentions, data.generate_dummies.py
is treated as a fully specified module path (that does not exist), and an attempt is made to import a submodule py
(that is also non-existent).
Invoke your file without .py
, if you're using the -m
flag, like this:
python -m data.generate_dummies
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With