# Application migrated from 7.9 to 8.1 - import command failure

**URL:** <https://forum.inductiveautomation.com/t/application-migrated-from-7-9-to-8-1-import-command-failure/73650>\
**Category:** Ignition\
**Tags:** ignition81, ignition79\
**Created:** [May 12, 2023, 2:29pm UTC](https://forum.inductiveautomation.com/t/application-migrated-from-7-9-to-8-1-import-command-failure/73650 "2023-05-12T14:29:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![szcz](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@szcz](https://forum.inductiveautomation.com/u/szcz)\
**Post date:** [May 12, 2023, 2:29pm UTC](https://forum.inductiveautomation.com/t/application-migrated-from-7-9-to-8-1-import-command-failure/73650/1 "2023-05-12T14:29:57Z")

</div>

Hi all,

I am moving an application from 7.9 to 8.1 and I am in the scripting part. 7.9 contains references to global scripts beginning with shared. which I update accordingly to 8.1 conventions. The application has lot of component events using the "shared" scripts in 7.9, I am transforming those to application-scoped scripts in this case while migrating.

I am getting errors on components calling those app scoped scripts (former global scripts) even while importing built-in packages (i.e. the script even does not begin execution, it is enough to reference a method from the script in the component event script to get the error on lines where the import begins):

The script begins with:

```auto
from java.util import Calendar
from java.util import Date
from calendar import monthrange
from time import gmtime, strftime
import time
import datetime
from datetime import datetime, timedelta

```

When I copy-paste in v8.1 these import commands to scripts editor, I get the same error as the component calling the script with those imports generates:

Java Traceback:  
Traceback (most recent call last):  
File "\<input\>", line 3, in   
File "C:\Users\my.username.ignition\cache\gwserver\_80\C0\pylib\calendar.py", line 9, in   
import datetime  
File "C:\Users\my.username.ignition\cache\gwserver\_80\C0\pylib\datetime.py", line 20, in   
import time as \_time  
java.lang.IllegalArgumentException: Cannot create PyString with non-byte value

... does anyone know how to approach this one?

Thank you

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 12, 2023, 3:08pm UTC](https://forum.inductiveautomation.com/t/application-migrated-from-7-9-to-8-1-import-command-failure/73650/2 "2023-05-12T15:08:33Z")

</div>

I vaguely recall seeing something like that. The Right Answer™ is to not use **any** of these:

```auto
from calendar import monthrange
from time import gmtime, strftime
import time
import datetime
from datetime import datetime, timedelta

```

Jython's date and time and calendar libraries are notoriously buggy in the java environment. Don't use them. At all.

You show java's `Date` and `Calendar` imports. Use those. Consider also the various java classes from `java.time`. Those are particularly useful for managing time zones in Perspective.

Side note:

> [@szcz](#):
>
> 7.9 contains references to global scripts beginning with shared. which I update accordingly to 8.1 conventions

Why? The conversion process to v8+ quite carefully sets things up so `shared.*` still works correctly, allowing you to migrate to new conventions when you **want to** , or want to use some inheritance feature, not because you immediately **need to**. Save this part for later.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 12, 2023, 3:21pm UTC](https://forum.inductiveautomation.com/t/application-migrated-from-7-9-to-8-1-import-command-failure/73650/3 "2023-05-12T15:21:34Z")

</div>

> [@szcz](#):
>
> Java Traceback:  
> Traceback (most recent call last):  
> File "", line 3, in  
> File "C:\Users\my.username.ignition\cache\gwserver\_80\C0\pylib\calendar.py", line 9, in  
> import datetime  
> File "C:\Users\my.username.ignition\cache\gwserver\_80\C0\pylib\datetime.py", line 20, in  
> import time as \_time  
> java.lang.IllegalArgumentException: Cannot create PyString with non-byte value

If that's truly the stacktrace, then this is 100% a Jython stdlib bug. Probably because the Jython stdlib you have is from whatever version of Ignition you originally started with, rather than whatever is current for Jython 2.7 in 8.X. You can stand up a new Ignition instance _from scratch_ and compare the `user-lib/pylib` folder to the files in your gateway backup, and bring in the newer files, which will likely patch over this bug.

Or, to Phil's point...just avoid the Jython standard library. Pretty much entirely. Java imports are guaranteed to be updated, because it's the runtime we're on. Python stuff can't be safely upgraded for you, so you have to do it manually.

---

<div class="post-metadata">

**Author:** ![szcz](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@szcz](https://forum.inductiveautomation.com/u/szcz)\
**Post date:** [May 12, 2023, 3:55pm UTC](https://forum.inductiveautomation.com/t/application-migrated-from-7-9-to-8-1-import-command-failure/73650/4 "2023-05-12T15:55:53Z")

</div>

Hello both, thank you for your valuable answers, appreciated. This decides my next steps.

To Phil's 7.9 to 8.1 migration point - good point sir, for majority of the projects I will use the path you have outlined, however for this one it's not possible due to reasons I don't want to bother you with.

Nevertheless, both comments have been of a tremendous value for me.
