Python 使用Intellij运行配置的交互式Powershell?
我有一个python脚本Python 使用Intellij运行配置的交互式Powershell?,python,powershell,intellij-idea,Python,Powershell,Intellij Idea,我有一个python脚本foo,它使用getpass提示输入密码。此python脚本在windows powershell命令行中工作: PS D:\Users\me\projects> foo Password: PS D:\Users\me\projects> .\bar.ps1 -bar_argument 42 bar_argument is: 42 calling foo Password: 我在powershell脚本中调用这个python脚本bar.ps1,在命令行中
foo
,它使用getpass
提示输入密码。此python脚本在windows powershell命令行中工作:
PS D:\Users\me\projects> foo
Password:
PS D:\Users\me\projects> .\bar.ps1 -bar_argument 42
bar_argument is: 42
calling foo
Password:
我在powershell脚本中调用这个python脚本bar.ps1
,在命令行中一切仍然正常:
PS D:\Users\me\projects> foo
Password:
PS D:\Users\me\projects> .\bar.ps1 -bar_argument 42
bar_argument is: 42
calling foo
Password:
当我在Intellij终端中运行脚本时,上述方法有效,但当我使用Intellij powershell插件设置powershell运行配置时,“密码:”提示从未出现,powershell脚本只是挂起:
C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe-文件D:\Users\me\projects\bar.ps1-bar\u参数42
bar_参数为:42
打电话给福
如何使用Intellij运行配置运行powershell脚本,并使脚本以交互方式工作(类似于命令行行为)?
提前感谢您的考虑和回复。您的python脚本需要以非交互方式运行,因为PowerShell脚本会这样调用它。将交互部分移动到PowerShell脚本,并将该值作为参数传递给python脚本 您的python脚本需要以非交互方式运行,因为PowerShell脚本会这样调用它。将交互部分移动到PowerShell脚本,并将该值作为参数传递给python脚本 虽然它不是powershell终端,但下面的代码对我有用
- win10
- 想法2019.1
- phyton 3.7.4(已安装:py启动器并将文件与phyton关联)
在IDEA windows终端中,执行以下命令
- 路径
并确保设置了phyton.exe的路径
使用py执行脚本。它应该在以下方面发挥作用:
虽然它不是powershell终端,但下面的代码对我有用
- win10
- 想法2019.1
- phyton 3.7.4(已安装:py启动器并将文件与phyton关联)
在IDEA windows终端中,执行以下命令
- 路径
并确保设置了phyton.exe的路径
使用py执行脚本。它应该在以下方面发挥作用:
谢谢您的回复。但是为什么在intellij中从终端
切换到运行
会改变行为?python被bar.ps1
以同样的方式调用,但是在run
版本中,交互性下降了……我不知道intellij,但我假设“Terminal”等同于“interactive”(正如您在提示符中键入的那样),“run”等同于“call a script”。如果您从一个脚本调用python,而该脚本没有可以连接的终端,那么该脚本将获得唯一的用户界面。感谢您的响应。但是为什么在intellij中从终端
切换到运行
会改变行为?python被bar.ps1
以同样的方式调用,但是在run
版本中,交互性下降了……我不知道intellij,但我假设“Terminal”等同于“interactive”(正如您在提示符中键入的那样),“run”等同于“call a script”。如果从一个脚本调用python,而该脚本没有可以连接的终端,那么该脚本将获得唯一的用户界面。