Search code examples
pythonmacospython-idle

MAC OS - os.system(command) display nothing


When I run IDLE (python 3.8) :

>>> import os
>>> os.system("ls")
0
>>> os.system('echo "test"')
0
>>> os.system("users")
0
>>> 

But if i do :

os.system("ls > test.txt") 

The test.txt file is created and contain the result.

I tried to reinstall and everything, nothing works... Only if I Run python in my terminal, command works but IDLE seems better for work.

Who could help me ? Thank you


Solution

  • I get the same issue and this is what I did:

    • Restart the IDLE.
    • Restart my laptop.

    However, the same problem persists.

    My suggestion is, instead of using IDLE, why don't you use the terminal? In my case, I use iTerm.

    $ python3.8
    $ >>> import os
    $ >>> os.system("ls")
    

    And everything works fine.