Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python解释器在Powershell ISE中崩溃_Python_Windows_Powershell_Powershell Ise - Fatal编程技术网

Python解释器在Powershell ISE中崩溃

Python解释器在Powershell ISE中崩溃,python,windows,powershell,powershell-ise,Python,Windows,Powershell,Powershell Ise,我已经在我的系统上安装了Python3,并且在路径中添加了可执行文件的路径。当我在Windows PowerShell(win8.1)中使用interpython时,它运行良好,但是我想使用PowerShell ISE来实现它的高级功能。但是,在PowerShell ISE中运行python会导致以下日志崩溃: python : Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)

我已经在我的系统上安装了Python3,并且在路径中添加了可执行文件的路径。当我在Windows PowerShell(win8.1)中使用inter
python
时,它运行良好,但是我想使用PowerShell ISE来实现它的高级功能。但是,在PowerShell ISE中运行
python
会导致以下日志崩溃:

python : Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
In Zeile:1 Zeichen:1
+ python
+ ~~~~~~
    + CategoryInfo          : NotSpecified: (Python 3.4.3 (v...ntel)] on win32:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Type "help", "copyright", "credits" or "license" for more information.
>>> 
(抱歉,部分是德语)

然后,我无法输入任何内容,必须按住Ctrl+C键才能返回PowerShell


这里可能有什么问题?

PowerShell ISE不适用于运行典型的交互式控制台程序,如python.exe。它隐藏控制台窗口并将标准输出重定向到管道。要在实践中看到这一点,请在ISE中运行以下命令:

python.exe -i -c "import ctypes; ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 5)"
在控制台窗口中输入文本,您将看到输入在控制台中回显,但输出通过管道传输到ISE


下面是一些关于Windows的简要概述。powershell.exe、cmd.exe和python.exe都是控制台应用程序,用作控制台服务器(或主机)进程conhost.exe的客户端。主机进程创建窗口并运行典型的GUI事件循环。当您从GUI应用程序(如explorer.exe)运行python.exe时,Windows将执行conhost.exe的新实例,这将创建一个新的控制台窗口。从另一个控制台应用程序(如powershell.exe)运行python.exe时,默认行为是继承父级的控制台

与连接的控制台主机通信。许多功能,例如,需要一个控制台输入或屏幕缓冲区。如果您连接到控制台,则特殊文件
CONIN$
表示输入缓冲区,
CONOUT$
是当前屏幕缓冲区,
CON
可以引用其中一个,具体取决于它是为读还是写而打开的。(您可能在cmd.exe中看到了命令,例如
copy con somefile.txt

Windows进程有三个字段用于标准I/O句柄。对于控制台进程,
StandardInput
默认为
CONIN$
的句柄,
StandardOutput
StandardError
默认为
CONOUT$
的句柄。C运行时库使用文件描述符0、1和2以标准的
stdin
stdout
stderr
的形式打开它们。启动进程时,可以将任何标准句柄设置为打开的文件或管道


虽然一个进程一次只能连接到一个控制台,但多个进程可以连接到一个控制台。但是,通常只有一个进程处于活动状态。例如,对于powershell.exe,在运行python.exe之后,其主线程正在后台等待python.exe退出。(请注意,如果在python.exe中启动另一个交互式控制台进程,然后退出,则此执行模型会严重失败,因为现在shell和子进程都在竞争对控制台的访问。)

好的,感谢您给出了深入的答案,如果您不想,您可以将其作为答案发布,我会接受。我认为它更适合于。你能在那里提问并提供一个新问题的链接吗?也许一个mod可以把这个问题转移到那里?