Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 581
Atia Avatar asked Nov 02 '25 10:11

Atia


1 Answers

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.

like image 157
Davis Herring Avatar answered Nov 04 '25 05:11

Davis Herring