08-02-2019 06:59 AM - edited 08-02-2019 07:02 AM
Hi,
I'm currently using the TestStand 2019 trial to evaluate if it suits the needs of our company. One critical aspect is compatibility with our existing Python code frameworks.
We are using an up-to-date Anaconda3 environment with Python 3.7. Everything is running 64 bit, and the TestStand adapter is configured and sees Python 3.7. When I try to run the "Computer Motherboard Test Sequence" demo for Python, I get following analysis error:
Message : Unable to load the the Python module.Error creating host process File : C:\Users\Public\Documents\National Instruments\TestStand 2019 (64-bit)\Examples\Demos\Computer Motherboard Test\Python\Computer Motherboard Test Sequence.seq Location : Seq["MainSequence"].Setup["Initialize Computer Test"].TS.SData.PythonCall.ModulePath Rule : Code modules must be able to load Description : TestStand must be able to load all code modules without error. TestStand reports errors at run time when it cannot load a code module. Correct this problem by editing the step in the sequence editor.
Occasionally it also shows error 17500, as described in this support article.
I'm somewhat stuck here. Changing Python version does not solve the issue, nor does manually creating a virtualenv environment and linking that to the adapter. The Anaconda folder is referenced by PATH, so that's not the issue either. If we just install the barebones Python 3.7.4 to the test-PC instead of our Anaconda environment, everything works fine and the demo runs without issue.
Are we missing some basic step somewhere or is Anaconda3 simply not supported? Please assist.
Solved! Go to Solution.
08-05-2019
03:48 AM
- last edited on
10-20-2024
07:25 PM
by
Content Cleaner
Hello,
Do you have Python Step Types for TestStand installed? If not, follow this link. Also, please make sure that all of the software that you are using is at the same bitness (32, 64),
08-05-2019 03:57 AM - edited 08-05-2019 04:01 AM
I'm using Teststand 2019, which according to what I can determine already has these Step Types pre-installed. The installer you link only appears to search for TestStand 2014-2017 installations.
As stated above, I'm using both Python and Teststand in 64 bit on a 64 bit operating system. The whole setup works fine on a barebones Python install, it's merely the combination with our company's Anaconda3 environment that throws the error. The TestStand Python Adapter recognizes the environment as a valid Python 3.7 version, the problems only occur when I actually try to run a script.
EDIT: Is there any way to enable more detailed error logging in TestStand, so we can try to debug what part of our Python environment the code module loader is having trouble with?
08-05-2019 04:01 AM
In similar cases from our customers they're also encountering problems with Anaconda, but everything works fine with the barebones Python. So my recommndation would be using just Python.
08-05-2019 04:05 AM
Are any fixes for this Anaconda issue planned? The Anaconda environment is an integral part of our production line, as it integrates a lot of packages we require. If TestStand can't deal with that our solution will simply be not to purchase TestStand, rather than try to maintain a separate Python environment for it.
08-05-2019
09:19 AM
- last edited on
10-20-2024
07:26 PM
by
Content Cleaner
Hey,
You could try to attach a debugger to try to uncover any finer details in the error message by using these steps -
https://www.ni.com/docs/en-US/bundle/teststand/page/debug-python-modules.html
Let us know if you find anything out.
Thanks,
Roxana
08-05-2019 11:50 AM
Wanted to add more info to may last post and ask a few more questions:
1. How did you make your environment if you're reffering to environments in the pythonic sense? TestStand only supports virtual environments that were created using the virtualenv tool.
2. Does the bitness of TestStand match with that of your Anaconda interperter?
Thanks,
Roxana
08-06-2019 01:17 AM
Hey Roxana,
Thanks for the suggestions. The bitness definitely matches. We initially attempted a Conda environment, but when we found that wasn't supported we also tried creating one through virtualenv with the same results.
Attaching the debugger gives me following message during the "Analyzing Sequence File" part:
Process name: niPythonHost.exe and Process ID: 12292
The exact Process ID varies randomly between multiple attempts at running the script.
With the debugger attached the sequence actually advances up to the first Python action instead of terminating immediately. But upon reaching the first piece of Python code it still crashes with a run-time error stating the interpreter session has crashed.
08-06-2019 06:53 AM
DCXenics,
I ran into similar issue and hope the following helps.
The error message you have posted is from TestStand Analyzer. However, if we ignore the analyzer error, enable displaying console for python (using Configure >> Adapters >> Python) and execute the sequence file, the console displayed the following error for me.
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
If you are also getting same error, then do the following to fix the issue (which I got from this link that mentions about issue in anaconda that supports python 3.7).
Assuming that you have installed Anaconda to 'C:\ProgramData\Anaconda3', set the following environment variables.
PYTHONHOME => C:\ProgramData\Anaconda3
PYTHONPATH => C:\ProgramData\Anaconda3\Lib
Setting the above two environment variable and restarting the application fixed the issue for me. Hopefully it will fix the issue for you too.
Based on this link, it seems that the issue was introduced by anaconda that supports python 3.7. Hence, if you can use anaconda that supports python 3.6 or earlier, there should be no issues. Also, as mentioned in this link, take extra care if you are using python virtual environment.
-Shashidhar
08-07-2019 01:31 AM
That seems to fix all problems! Thank you very much, Shashidhar.