Py3 Conversion Issue using from __future__

Posted on
Sun Dec 04, 2022 4:16 pm
automaton offline
Posts: 88
Joined: May 23, 2008

Py3 Conversion Issue using from __future__

I'm converting some external scripts to py3 which are executed by indigo. I used some of the automatic converters to upgrade my code.

I get this error when executing (from a schedule):
Code: Select all
Dec 4, 2022 at 2:07:50 PM
   Script Error                    schedule "NOAA Alert Check CAP 2.20 Py3" script error in file noaa-cap-poller-py3-2.20.py:
   Script Error                    from __future__ imports must occur at the beginning of the file
   Script Error                    around line 1


However, the from __future__ statement is in the first line of the code:

Code: Select all
from __future__ import absolute_import
from __future__ import print_function
import sys
import os
...


Is this not supported for py3 under Indigo, or am I making a rookie mistake?

Posted on
Sun Dec 04, 2022 4:58 pm
DaveL17 offline
User avatar
Posts: 6751
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Py3 Conversion Issue using from __future__

I'm not sure, but I'll take a guess. Are you running this script as an embedded script? If so, try running it as a linked script instead.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Dec 05, 2022 10:53 am
jay (support) offline
Site Admin
User avatar
Posts: 18212
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Py3 Conversion Issue using from __future__

I don't think you need those two future imports - I think they were shims in Python 2 to make the behavior mirror Python 3. I could be wrong, but try it without them.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Dec 08, 2022 10:22 am
automaton offline
Posts: 88
Joined: May 23, 2008

Re: Py3 Conversion Issue using from __future__

Removing them seems to be the trick. Thanks.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests