I have seen some other posts for this issue and the most recent one was not resolved. I went through and uninstalled, cleared cache, reinstalled Jython, and I am at a loss.
Jython 2.7.1 (default:0df7adb1b397, Jun 30 2017, 19:02:43)
[OpenJDK 64-Bit Server VM (Azul Systems, Inc.)] on java11.0.9
>>> ImportError: Cannot import site module and its dependencies: Error loading module DevceList: Traceback (most recent call last):
File "<module:DevceList>", line 1, in <module>
NameError: name 'system' is not defined
Determine if the following attributes are correct:
* sys.path: [C:\Users\rdlab\.ignition\cache\gw10.10.5.10_80\C0\pylib, C:\Users\rdlab\.ignition\cache\resources\platform\jython-2.7.1-ia5.jar\000000001498F8CC\Lib, __classpath__, __pyclasspath__/]
This attribute might be including the wrong directories, such as from CPython
* sys.prefix: C:\Users\rdlab\.ignition\cache\resources\platform\jython-2.7.1-ia5.jar\000000001498F8CC
This attribute is set by the system property python.home, although it can
be often automatically determined by the location of the Jython jar file
You can use the -S option or python.import.site=false to not import the site module
What do your project scripts look like? Do you have one named system
or any other reserved name? Is it possible thereâs a line in any of your scripts thatâs reassigning system
to something else? As in, system = xyz
, inadvertently.
https://docs.inductiveautomation.com/display/DOC81/system.device.listDevices
was playing around with this and the only place it says system is in the system.device.listDevices
Do you have a script called DeviceList?
Sorry, I hit reply before finishingâŚ
EDIT: What are the contents of the script?
1 Like
You have good taste. lol
Can you give a screen shot of where the script is located?
I was just trying it out in the console, it does send a single value to my dataset.
The error is implicating a project script library called DevceList
[sic] - what youâre doing in the script console is unrelated to whatâs actually causing the error.
1 Like
Yup look at that, just needed to nuke some scripts and all fixed.
2 Likes
I can start a new thread but just curious now that I have it all working.
[[u'Compact 5480', True, u'Connected', u'LogixDriver'], [u'SimValues', True, u'Running', u'ProgrammableSimulatorDevice'], [u'Moxa Port 502', True, u'Connected', u'ModbusRtuOverTcp']]
Why am I getting a uâ in front of 3/4 of the columns? Is that from ignition?
No, thatâs a Python (2) ism. u
in front of a string literal (you can also provide it yourself, e.g. myString = u'ÎÎżĎξΟ ΚĎĎθΟ δοΝοĎ'
is valid code) means that itâs a âUnicodeâ string - normal Python strings can only hold the 255 characters in the standard ASCII range, which has obvious problems for internationalization/localization. Most Ignition APIs should default to returning Unicode strings.
As a consumer of the values in scripting, you shouldnât ever really have to care; a Unicode string acts just like a âregularâ ASCII string.
2 Likes
I faced this same issue, only with âsystemâ, as in âsystem.util.getLoggerâ.
I had originally written the script on another server and copy-and-pasted the script to my new project. My guess is that there other hidden data attached to the script when copying from the Project Library to another. I copied the Project Script contents to NotePad++ â Deleted the Script from the Project Library â created a brand new Script with a slightly different Name (e.g. âamr_statsâ to âamrStatsâ) â pasted the copied, old Script. Lo and Behold, the error messages disappeared.
I just upgraded to Ignition 8.1.17
I find it interesting that if I have a syntax error in my Project Library script, the Script Console displays the error.
ImportError: Cannot import site module and its dependencies: Error loading module GEO: NameError: name 'x' is not defined
Determine if the following attributes are correct:
* sys.path: [C:\Users\lynn.martineau\.ignition\cache\gwotc-mesopc01_8088\C0\pylib, C:\Users\lynn.martineau\.ignition\cache\resources\platform\jython-ia-2.7.2.1.jar\00000000A5AE7F4C\Lib, __classpath__, __pyclasspath__/]
This attribute might be including the wrong directories, such as from CPython
* sys.prefix: C:\Users\lynn.martineau\.ignition\cache\resources\platform\jython-ia-2.7.2.1.jar\00000000A5AE7F4C
This attribute is set by the system property python.home, although it can
be often automatically determined by the location of the Jython jar file
You can use the -S option or python.import.site=false to not import the site module
In this case, I had an âxâ in column 1 where a âdefâ would normally be.