[英]Python os.system() uses cmd on windows, any ways I can change to my ubuntu terminal?
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. 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
谢谢
Per the Python docs , os.system(<command>)
executes <command>
in a subshell, which is system dependent.根据Python docs ,
os.system(<command>)
在子shell中执行<command>
,这取决于系统。 There is no way to make os.system()
run a Windows specific command as a Unix equivalent.没有办法让
os.system()
运行 Windows 特定命令作为 Unix 等效命令。 You may be interested in Python's sys module你可能对 Python 的sys 模块感兴趣
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.如果您使用有关您尝试运行的命令的更具体细节来编辑您的问题,我可能会提供更好的帮助。
os.system() normally runs system commands depending the OS you are running the script. os.system() 通常根据您运行脚本的操作系统运行系统命令。 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.
但是,您可以阅读有关Stackoverflow的这篇文章,或尝试按照进一步的步骤为 Windows 上的 Ubuntu 上的 Python 设置有效环境。
- Install Bash on Windows
在 Windows 上安装 Bash
- Check for updates
检查更新
- Check out the REPL
查看 REPL
- Install Pip
安装Pip
- Install VirtualEnv
安装 VirtualEnv
- Install VirtualEnvWrapper
安装 VirtualEnvWrapper
- Create your first virtualenv
创建你的第一个 virtualenv
- Configure bashrc to keep it working More detailes here
配置 bashrc 以使其保持工作更多详细信息here
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.