Is there a Python library to run Bash commands in a non-Linux OS? I want to run Bash commands in Windows using Python. Is there a Python library for that? Please help.

PS- should have an easy syntax. I don't want stuff with auth keys, etc.

  • which bash commands would you like to run in particular, and do they have to be Python functions? Many bash programs have versions compiled for Windows and can be called from Python as subprocesses.
    – Tymric
    Feb 19, 2023 at 5:27
  • actually i want some thing like this - run_bash("echo 'hey' | lolcat"). and almost all of the commands must work. note that it'll be a bonus if i can run sudo and apt-get
    – lunix
    Feb 19, 2023 at 9:32
  • Your questions asked here are very vague and mostly unrealistic. This one is caused by lack of knowledge it seems - I don't think you understand what "bash commands" are and why this Python library question doesn't make much sense. You can run any sort of CLI command in Python and your question should be how you should get them in your system. But then you need to be specific about which commands and which system. If Windows, then you have e.g. Cygwin. But if you are talking about stuff such as lolcat then that's a random 3rd party exec. And apt-get has no purpose on incompatible systems
    – Destroy666
    Feb 19, 2023 at 20:03
  • apt-get WIndows alternatives would be choco or winget that target correct repositories with types of installers or executables that work in Windows
    – Destroy666
    Feb 19, 2023 at 20:04
  • okay. so what about the others??
    – lunix
    Feb 20, 2023 at 9:55


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.