简体   繁体   English

How can I configure PyCharm's Python console so that I can run Linux shell commands on Ubuntu 18.04 WSL?

[英]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.

相关问题 如何配置PyCharm,以便在Python控制台中可以看到正在运行的Python脚本文件 - how can I configure PyCharm so that running a Python script file is visible for Python Console 如何在 WSL Ubuntu 20.04 环境中从 Windows 中的 Python 脚本启动命令 - How can I launch commands from a Python script in Windows in a WSL Ubuntu 20.04 environment 如何从 Python 运行云 shell 命令? - How can I run cloud shell commands from Python? 如何配置 PyCharm 以便它自动安装任何缺少的 Python 包? - How can I configure PyCharm so that it automatically installs any missing Python package? 如何在使用脚本的调试模式(Linux机器)时在pycharm中激活wsl中的虚拟环境 - How Can I activate virtual environment in wsl in pycharm while using debug mode of a script (Linux machine) 如何让PyCharm在现有控制台中运行当前文件? - How can I make PyCharm run the current file in the existing console? 无法在python控制台上运行此命令,但我可以在python shell中运行 - Cant run this on python console but i can in the python shell 如何使用PyCharm的控制台访问Python命令行? - How can I access the Python command line using PyCharm's console? 如何在 PyCharm Python 控制台中获取彩色日志以正确格式化? - How can I get coloredlogs in PyCharm Python Console to format properly? 如何通过 Windows 上的 Python 子进程一次运行多个 shell 命令? - How can I run multiple shell commands at once through a Python subprocess on Windows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM