NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Python import from subfolder fails with ModuleNotFoundError

I am using Teststand 2019 32bit Evaluation with Python 3.6.3 32bit. 

 

The main python file (eval.py) imports a module (module2.py) located in a subdirectory named 'windows' which is located in the same folder as eval.py.

 

A Python action step is added to the Teststand sequence to create a class instance defined in eval.py to a StationGlobal object. The eval.py code is as follows:

 

class eval():

    def __init__(self)

        from windows.module2 import module2

        self.mod2 = module2()

 

The import line however fails with <class 'ModuleNotFoundError'> No module named 'windows'

 

When eval.py is run using python36 in command terminal it works.

 

The following has been checked:

The Python adapter is properly configured and selected

The directory containing eval.py and windows directory is added to the Teststand Search Directories (with subfolders enabled)

PATH Environment variable is selected

An empty __init__.py file is added to the 'windows' subfolder (some forums suggested this)

Absolute or relative module loading did not make a difference

 

The above mentioned sequence file initially worked on a different fully licensed Teststand 2019 32bit installation running on a different computer but after the second or third run it started to give the same error.

 

 

 

 

0 Kudos
Message 1 of 2
(2,618 Views)

Hello,

 

Could you please attach your project?

__________________________________________
The best way to thank, is to give KUDOS
0 Kudos
Message 2 of 2
(2,566 Views)