Running Python scripts
We have created a simple main.py file inside the project, now run your python scripts using the following command below:
$ poetry run python new_project/main.py
Example 1:
Create a new file with main.py.
Python3
# where main.py contains print ( "Hello World" ) |
Output:
Example 2:
In this program we are going to use various dependencies which are time and plyer to add those dependencies to our project simply use the following commands:
$ poetry add plyer datetime
Create a new file with notifier.py.
Python3
from plyer import notification import time def inputtime(): hour = int ( input ( "hours of interval :" )) minutes = int ( input ( "Mins of interval :" )) seconds = int ( input ( "Secs of interval :" )) time_interval = seconds + (minutes * 60 ) + (hour * 3600 ) return time_interval def notify(): notification.notify( title = "Time is Up" , message = "Enter description here" , timeout = 5 ) if __name__ = = '__main__' : time_interval = inputtime() time.sleep(time_interval) notify() |
Run Program
$ poetry run python notifier/notifier.py
Output:
Using Poetry Dependency Management tool in Python
In this article, we are going to study the poetry dependency management tool in python which will help you to manage the libraries of your next project so it will be easy to download, install, and set up your project.
Contact Us