NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Error "-17500" Using Python and TestStand

Solved!
Go to solution

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.

0 Kudos
Message 1 of 10
(5,518 Views)

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),

0 Kudos
Message 2 of 10
(5,471 Views)

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?

0 Kudos
Message 3 of 10
(5,465 Views)

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.

0 Kudos
Message 4 of 10
(5,457 Views)

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.

0 Kudos
Message 5 of 10
(5,452 Views)

Hey, 

 

You could try to attach a debugger to try to uncover any finer details in the error message by using these steps - 

 

https://zone.ni.com/reference/en-XX/help/370052AA-01/tsref/infotopics/debugging_python_module/

 

Let us know if you find anything out. 

Thanks,

Roxana

Message 6 of 10
(5,432 Views)

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

0 Kudos
Message 7 of 10
(5,421 Views)

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.

 

 

0 Kudos
Message 8 of 10
(5,401 Views)
Solution
Accepted by DCXenics

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

Message 9 of 10
(5,386 Views)

That seems to fix all problems! Thank you very much, Shashidhar.

0 Kudos
Message 10 of 10
(5,351 Views)