How to run a Python package with one command line [closed]
I'm a newbie in Python. And I don't know how to run a python package with only one command line. I have been searched it on GG but I have no key-word.
There is my folder:
├── config.json
└── my_source
├──__init__.py
├──filter.py
└──get_new_users.py
And config.json contains 3 parameters and able change by the user. So, I want to run this my_source package with one command line like this:
my_source -c config.json
Could I able to run my code in this way?
If it's possible. Could anyone give me a key-word or a way to do it? If you need more info, please leave a comment. Thank you.
python python-3.x
closed as too broad by Goyo, Owen Pauling, EdChum, Rob, David Kemp Nov 23 '18 at 17:19
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
I'm a newbie in Python. And I don't know how to run a python package with only one command line. I have been searched it on GG but I have no key-word.
There is my folder:
├── config.json
└── my_source
├──__init__.py
├──filter.py
└──get_new_users.py
And config.json contains 3 parameters and able change by the user. So, I want to run this my_source package with one command line like this:
my_source -c config.json
Could I able to run my code in this way?
If it's possible. Could anyone give me a key-word or a way to do it? If you need more info, please leave a comment. Thank you.
python python-3.x
closed as too broad by Goyo, Owen Pauling, EdChum, Rob, David Kemp Nov 23 '18 at 17:19
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
you mean execute the script?
– Kunal Mukherjee
Nov 23 '18 at 8:16
you are right. @KunalMukherjee
– Han Van Pham
Nov 23 '18 at 9:31
add a comment |
I'm a newbie in Python. And I don't know how to run a python package with only one command line. I have been searched it on GG but I have no key-word.
There is my folder:
├── config.json
└── my_source
├──__init__.py
├──filter.py
└──get_new_users.py
And config.json contains 3 parameters and able change by the user. So, I want to run this my_source package with one command line like this:
my_source -c config.json
Could I able to run my code in this way?
If it's possible. Could anyone give me a key-word or a way to do it? If you need more info, please leave a comment. Thank you.
python python-3.x
I'm a newbie in Python. And I don't know how to run a python package with only one command line. I have been searched it on GG but I have no key-word.
There is my folder:
├── config.json
└── my_source
├──__init__.py
├──filter.py
└──get_new_users.py
And config.json contains 3 parameters and able change by the user. So, I want to run this my_source package with one command line like this:
my_source -c config.json
Could I able to run my code in this way?
If it's possible. Could anyone give me a key-word or a way to do it? If you need more info, please leave a comment. Thank you.
python python-3.x
python python-3.x
edited Nov 23 '18 at 9:32
Han Van Pham
asked Nov 23 '18 at 8:09
Han Van PhamHan Van Pham
608
608
closed as too broad by Goyo, Owen Pauling, EdChum, Rob, David Kemp Nov 23 '18 at 17:19
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as too broad by Goyo, Owen Pauling, EdChum, Rob, David Kemp Nov 23 '18 at 17:19
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
you mean execute the script?
– Kunal Mukherjee
Nov 23 '18 at 8:16
you are right. @KunalMukherjee
– Han Van Pham
Nov 23 '18 at 9:31
add a comment |
you mean execute the script?
– Kunal Mukherjee
Nov 23 '18 at 8:16
you are right. @KunalMukherjee
– Han Van Pham
Nov 23 '18 at 9:31
you mean execute the script?
– Kunal Mukherjee
Nov 23 '18 at 8:16
you mean execute the script?
– Kunal Mukherjee
Nov 23 '18 at 8:16
you are right. @KunalMukherjee
– Han Van Pham
Nov 23 '18 at 9:31
you are right. @KunalMukherjee
– Han Van Pham
Nov 23 '18 at 9:31
add a comment |
2 Answers
2
active
oldest
votes
To run a python module/package specify the -m flag.
For example in your situation it will be something like:
python -m my_course.filter
See this SO question for more info.
add a comment |
It's not clear what you mean "run a folder". Rather you can import the folder as a module, in other code, say app.py
├── config.json
├── app.py
└── my_source
├──__init__.py
├──filter.py
└──get_new_users.py
And do from my_source import *
within app.py
to use the function/variables defined there
Then, run python app.py
, and pass config.json
somehow depending on the internals of that code
Thank you. In case if I want to make it as a package. How can I run it?
– Han Van Pham
Nov 23 '18 at 8:36
1
Perhaps you can check some documentation about packages? docs.python.org/3/tutorial/modules.html#packages
– cricket_007
Nov 23 '18 at 16:18
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
To run a python module/package specify the -m flag.
For example in your situation it will be something like:
python -m my_course.filter
See this SO question for more info.
add a comment |
To run a python module/package specify the -m flag.
For example in your situation it will be something like:
python -m my_course.filter
See this SO question for more info.
add a comment |
To run a python module/package specify the -m flag.
For example in your situation it will be something like:
python -m my_course.filter
See this SO question for more info.
To run a python module/package specify the -m flag.
For example in your situation it will be something like:
python -m my_course.filter
See this SO question for more info.
answered Nov 23 '18 at 10:44
Kunal MukherjeeKunal Mukherjee
1,3212825
1,3212825
add a comment |
add a comment |
It's not clear what you mean "run a folder". Rather you can import the folder as a module, in other code, say app.py
├── config.json
├── app.py
└── my_source
├──__init__.py
├──filter.py
└──get_new_users.py
And do from my_source import *
within app.py
to use the function/variables defined there
Then, run python app.py
, and pass config.json
somehow depending on the internals of that code
Thank you. In case if I want to make it as a package. How can I run it?
– Han Van Pham
Nov 23 '18 at 8:36
1
Perhaps you can check some documentation about packages? docs.python.org/3/tutorial/modules.html#packages
– cricket_007
Nov 23 '18 at 16:18
add a comment |
It's not clear what you mean "run a folder". Rather you can import the folder as a module, in other code, say app.py
├── config.json
├── app.py
└── my_source
├──__init__.py
├──filter.py
└──get_new_users.py
And do from my_source import *
within app.py
to use the function/variables defined there
Then, run python app.py
, and pass config.json
somehow depending on the internals of that code
Thank you. In case if I want to make it as a package. How can I run it?
– Han Van Pham
Nov 23 '18 at 8:36
1
Perhaps you can check some documentation about packages? docs.python.org/3/tutorial/modules.html#packages
– cricket_007
Nov 23 '18 at 16:18
add a comment |
It's not clear what you mean "run a folder". Rather you can import the folder as a module, in other code, say app.py
├── config.json
├── app.py
└── my_source
├──__init__.py
├──filter.py
└──get_new_users.py
And do from my_source import *
within app.py
to use the function/variables defined there
Then, run python app.py
, and pass config.json
somehow depending on the internals of that code
It's not clear what you mean "run a folder". Rather you can import the folder as a module, in other code, say app.py
├── config.json
├── app.py
└── my_source
├──__init__.py
├──filter.py
└──get_new_users.py
And do from my_source import *
within app.py
to use the function/variables defined there
Then, run python app.py
, and pass config.json
somehow depending on the internals of that code
answered Nov 23 '18 at 8:16
cricket_007cricket_007
81.8k1143111
81.8k1143111
Thank you. In case if I want to make it as a package. How can I run it?
– Han Van Pham
Nov 23 '18 at 8:36
1
Perhaps you can check some documentation about packages? docs.python.org/3/tutorial/modules.html#packages
– cricket_007
Nov 23 '18 at 16:18
add a comment |
Thank you. In case if I want to make it as a package. How can I run it?
– Han Van Pham
Nov 23 '18 at 8:36
1
Perhaps you can check some documentation about packages? docs.python.org/3/tutorial/modules.html#packages
– cricket_007
Nov 23 '18 at 16:18
Thank you. In case if I want to make it as a package. How can I run it?
– Han Van Pham
Nov 23 '18 at 8:36
Thank you. In case if I want to make it as a package. How can I run it?
– Han Van Pham
Nov 23 '18 at 8:36
1
1
Perhaps you can check some documentation about packages? docs.python.org/3/tutorial/modules.html#packages
– cricket_007
Nov 23 '18 at 16:18
Perhaps you can check some documentation about packages? docs.python.org/3/tutorial/modules.html#packages
– cricket_007
Nov 23 '18 at 16:18
add a comment |
you mean execute the script?
– Kunal Mukherjee
Nov 23 '18 at 8:16
you are right. @KunalMukherjee
– Han Van Pham
Nov 23 '18 at 9:31