Reputation: 21
I am trying to run a stand-alone python file partitions.py that is in my home folder. When I type the command "python3 partition.py" the script runs.
However, when I type "python3 -m partition.py" it gives me an error "/usr/local/bin/python3: No module named partition.py"
I do not know why this is the case. Any help would be greatly appreciated. Thanks
Upvotes: 0
Views: 103
Reputation: 2689
See the doc, specifically that the module must be on the path, and the extension shouldn't be included.
Upvotes: 0
Reputation: 69042
To run the module as script directly use:
python3 -m partition
(without the .py
ending).
That will cause python to search sys.path
for a module called partition
and execute it. partition.py
in this context would mean a module in a file partition/py.py
.
Upvotes: 4