简体   繁体   中英

python opens new console window instead of printing into cmd

My Python 3 (3.6) opens new black console window for each Python command I run ( pip is just the same).

Example: When I create a hello_world.py with a while True: print("hello world") Loop in it and start it from PowerShell via python test.py it will open a new window, print "hello world" in the new window and leave the console I used to run the script empty... (same happens with Cygwin) using CMD it won't even open the Python window and just closes gives me back a new CMD prompt-line.

Even worse when using PyCharm each time a background-task runs (eg syntax-check) a black console window opens for ~1 sec. and thus blocks me from writing code.

Example images to show what is happening:

Code used for test.py:

while True:
    print("Hello World")

示例 1

示例 2

So far I tried:

  • creating and modifying manifest files for python.exe / pythonw.exe
  • reinstalling Python3
  • installing a different Python3 Version
  • changing the default codepage for CMD/PowerShell
  • setting PYTHONENCODING and PYTHONIOENCODING to UTF-8
  • starting PowerShell/Python as admin

//edit:

the Question is: How can I get back the default Python behavior, as seen on every other (Windows) Computer.

我发现解决方案只是以管理员身份运行 cmd 或 powershell,任何其他类型的用户都会导致此问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM