Reputation: 101
I wrote script, and if I run it from Pycharm - everything runs ok. No problems at all.
But, if I run it from terminal I receive error:
Import by filename is not supported
I have the project that consists of four packages and in the packages the files have some imports between files.
I run it by command:
python -m ~/PycharmProjects/name_of_projects/package_main/main.py
Import:
from package_name_1.file_1 import *
from package_name_1.file_2 import *
Upvotes: 0
Views: 913
Reputation: 2484
python --help
says:
-m mod : run library module as a script (terminates option list)
By this, it means that mod
should be something that the Python interpreter can import
, i.e., a module located on PYTHONPATH
. It's used for running some package, like a debugger, with your script as an argument, e.g.,
python -m ipdb myscript.py
would debug myscript.py
instead of just running it (if ipdb
is an installed package).
Just as you cannot write
import ~/PycharmProjects/name_of_projects/package_main/main.py
within your script, you cannot pass that argument to -m
.
Is there a reason you're not calling
python ~/PycharmProjects/name_of_projects/package_main/main.py
without -m
?
Upvotes: 1