Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my python script just open IDLE?

Tags:

python

I can't understand why running my Python program just opens IDLE.

Not sure if this is more appropriate on SuperUser, but here goes: I can't run python scripts from my command line.

OSX 10.7.4, fresh install of python 3.2.3. I've got the following python script as test.py:

#! /usr/bin/env python
print("hello world")

I then make it executable:

$> chmod +x test.py

Then all of the following cause the terminal to open IDLE, with no other output of any kind, i.e. the script is not run:

  • python test.py
  • python -i test.py
  • ./test.py

Even python -c 'print(5)' dumps me into IDLE without actually executing the command! IDLE itself works fine. Anyone know what could be going on?

like image 418
Chris Avatar asked Apr 25 '26 18:04

Chris


1 Answers

Not very sure about the problem, but have you tried to run


python3 test.py

or change the shebang line to python3?

trying to take a look at the content in your "python" console script (e.g. by file which python) may also help reveal why it is linked to IDLE.

like image 140
dolaameng Avatar answered Apr 27 '26 07:04

dolaameng



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!