Search code examples
linuxterminalpackage

How to run an installed python package from terminal


I have a python code like so

wallpaper/
   setup.py
   wallpaper/
      __init__.py
      environments.py
      run.py

The run.py has a function like so:

import environments

def main():
   .. do something()
if __name__=='__main__':
   main()

After installing this package how do I execute the run.py script on my terminal. I realize this question has been asked before but I wasn't satisfied with that answer as it did not offer me any insight.


Solution

  • You want

    python -m wallpaper.run
    

    This relies on PYTHONPATH being set properly; you may need to restart your terminal if the package was just installed in a new directory.