How to run a Python package with one command line [closed]












0















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.










share|improve this 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
















0















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.










share|improve this 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














0












0








0








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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



















  • 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












2 Answers
2






active

oldest

votes


















1















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.






share|improve this answer































    3














    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






    share|improve this answer
























    • 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


















    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1















    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.






    share|improve this answer




























      1















      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.






      share|improve this answer


























        1












        1








        1








        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.






        share|improve this answer














        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 10:44









        Kunal MukherjeeKunal Mukherjee

        1,3212825




        1,3212825

























            3














            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






            share|improve this answer
























            • 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
















            3














            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






            share|improve this answer
























            • 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














            3












            3








            3







            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






            share|improve this answer













            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







            share|improve this answer












            share|improve this answer



            share|improve this answer










            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



















            • 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



            Popular posts from this blog

            Costa Masnaga

            Fotorealismo

            Sidney Franklin