LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-25-2018, 06:02 PM   #1
iceman81
Member
 
Registered: Jan 2013
Location: New Jersey
Distribution: CentOS, Arch
Posts: 181

Rep: Reputation: Disabled
python script issue


Hey guys, started a python book, and while everything works fine with the idle IDE, when i try to run in the terminal, i get errors.

Code:
 print("Game Over")
this is the only code in the "print.py" file, which was saved directly from the IDLE script window.

after making it executable with chmod, here is my output

Code:
ant@ant-chrome ~/python $ ./print.py
./print.py: line 1: syntax error near unexpected token `"Game Over"'
./print.py: line 1: `print("Game Over")'
ant@ant-chrome ~/python $
also, i am using python 3.5.2 shell in IDLE, and thats also what "python --version" outputs in the cli as well.

What am I doing wrong?
 
Old 04-25-2018, 06:20 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,222

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
You're missing the shebang. The file should start with:

Code:
#!/usr/bin/env python3
 
1 members found this post helpful.
Old 04-25-2018, 06:33 PM   #3
iceman81
Member
 
Registered: Jan 2013
Location: New Jersey
Distribution: CentOS, Arch
Posts: 181

Original Poster
Rep: Reputation: Disabled
thank you
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Python tricks for artists: How to add interactivity to any Python script LXer Syndicated Linux News 0 03-16-2017 06:12 PM
[SOLVED] Issue with cron scheduling python script which includes webdriver testcase Sukh Linux - Newbie 2 08-10-2012 05:23 AM
How to close open ports using a python script or a shell script in python ?? apanimesh061 Programming 3 11-20-2011 12:31 AM
Python related: How to access a Perl script behind a firewall from Python? vxc69 Programming 8 12-14-2010 07:32 AM
Python Script Issue* Millenniumman Programming 1 06-18-2006 09:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration