Home > Enterprise >  Python os.system() uses cmd on windows, any ways I can change to my ubuntu terminal?
Python os.system() uses cmd on windows, any ways I can change to my ubuntu terminal?

Time:07-27

I feel uncomfortable using cmd and I want to use commands for my python scripts, wondering if there is any way to not use cmd for os.system() and instead changes that to my ubuntu terminal. Thanks!

CodePudding user response:

Per the Python docs, os.system(<command>) executes <command> in a subshell, which is system dependent. There is no way to make os.system() run a Windows specific command as a Unix equivalent. You may be interested in Python's sys module

If you edit your question with more specific details as to what commands you are trying to run I might be able to provide better help.

CodePudding user response:

os.system() normally runs system commands depending the OS you are running the script. However, you can read this article on Stackoverflow or try to follow further steps to setup an effective environment for Python on Ubuntu on Windows.

  1. Install Bash on Windows
  2. Check for updates
  3. Check out the REPL
  4. Install Pip
  5. Install VirtualEnv
  6. Install VirtualEnvWrapper
  7. Create your first virtualenv
  8. Configure bashrc to keep it working More detailes here
  • Related