[英]How can I configure PyCharm's Python console so that I can run Linux shell commands on Ubuntu 18.04 WSL?
I have installed Ubuntu 18.04 subsystem on Windows 10, and I need to use python subprocess library to execute Linux commands. I have installed Ubuntu 18.04 subsystem on Windows 10, and I need to use python subprocess library to execute Linux commands. However my PyCharm python console only accepts Microsoft shell commands, even though my python script is in my Ubuntu folder. However my PyCharm python console only accepts Microsoft shell commands, even though my python script is in my Ubuntu folder.
Running PyCharm in windows, the subprocess can only run windows cmd commands.在windows中运行PyCharm,子进程只能运行windows ZDFFF0A7FA1A55C6452A4966C4F命令。 However, windows allows several ways to run wsl or bash commands once you have a Linux distro installed.但是,一旦您安装了 Linux 发行版,windows 允许通过多种方式运行 wsl 或 bash 命令。
Either use要么使用
bash -c [command]
Or或者
wsl [command]
As your first arguments for the command you want to run in subprocess.作为您要在子进程中运行的命令的第一个 arguments。 You can even specify specific distros to run that command on if you have more than one installed.如果您安装了多个,您甚至可以指定特定的发行版来运行该命令。 You can read more of the documentation for it here: https://devblogs.microsoft.com/commandline/a-guide-to-invoking-wsl/您可以在此处阅读更多相关文档: https://devblogs.microsoft.com/commandline/a-guide-to-invoking-wsl/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.