Python Forum
code works in python shell, but not in a terminal
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
code works in python shell, but not in a terminal
#1
I have a simple program to put passport size photos next to the correct name in an excel table.

In the python shell, everything works and it does just what I want.

I use Ubuntu 16.04. When I start a terminal and run the program, I get the following error: (the ^ does not display properly on this web page, in a terminal it is directly under the :)

Quote:pedro@pedro-dodgySSD:~/myPython$ ./putPicsinColumn1version4.py
File "./putPicsinColumn1version4.py", line 75
for sheet in sheets:
^
SyntaxError: invalid syntax
pedro@pedro-dodgySSD:~/myPython$

This seems to tell me the colon is wrong, but I'm certain it is needed in Python.

Line 75 is the first line below, the code is:

for sheet in sheets:
      wb.active = wb[sheet]
      print('Active Sheet is ' + str(wb.active))
      print('Max row is ' + str(wb.active.max_row))
      for rowNum in range(beginRow, wb.active.max_row + 1):
          print('resizing row height in ' + str(wb.active))
          wb.active.row_dimensions[rowNum].height = 72 # about 1"
As I said, this works when I test it in the idle shell, just not when I want to run it in terminal. Anyone know why? Anyone had this kind of problem?
Reply


Messages In This Thread
code works in python shell, but not in a terminal - by Pedroski55 - Sep-08-2018, 03:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  My code works on Jupyter Lab/Notebook, but NOT on Visual Code Editor jst 4 1,323 Nov-15-2023, 06:56 PM
Last Post: jst
  Help creating shell scrip for python file marciokoko 10 1,558 Sep-16-2023, 09:46 PM
Last Post: snippsat
  invoking python in Terminal Euler 2 697 Aug-25-2023, 06:17 AM
Last Post: perfringo
  Code works but doesn't give the right results colin_dent 2 814 Jun-22-2023, 06:04 PM
Last Post: jefsummers
  Launch Python IDLE Shell from terminal Pavel_47 5 1,397 Feb-17-2023, 02:53 PM
Last Post: Pavel_47
  Python VS Code: using print command twice but not getting output from terminal kdx264 4 1,220 Jan-16-2023, 07:38 PM
Last Post: Skaperen
  Code used to work 100%, now sometimes works! muzicman0 5 1,595 Jan-13-2023, 05:09 PM
Last Post: muzicman0
  Can a program execute code in iPython shell and get result? deanhystad 3 1,839 Jun-17-2022, 03:45 AM
Last Post: Larz60+
  batch file for running python scipt in Windows shell MaartenRo 2 2,028 Jan-21-2022, 02:36 PM
Last Post: MaartenRo
  Pyspark - my code works but I want to make it better Kevin 1 1,880 Dec-01-2021, 05:04 AM
Last Post: Kevin

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020