NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Python steps 'import pylink' give c++ DLL error, when trying to modify step

Solved!
Go to solution

I am using Python steps. That works fine execpt when I have a Python file which imports pylink (https://pylink.readthedocs.io/en/latest/)

It compaints it can not load a DLL:

"DLL load failed: A dynamic link library (DLL) initialization routine failed."

 

Inside pylink it seems to go wrong on:

from .enums import *
', ' File "C:\WinPython\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\pylink\enums.py", line 15, in
import ctypes
', ' File "C:\WinPython\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\Lib\ctypes\__init__.py", line 10, in
from _ctypes import Union, Structure, Array
', 'ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
'][Error Code: -17500]

 

If I try to edit the step I get the error "Microsoft Visual C++ Runtime Library, Runtime error!, R6034 An application has made an attempt to load a C runtime library incorrectly"

Please note:

  • I have installed Microsoft Visual C++ Redistibutable (x86) on the machine.
  • Outside teststand there is no issue at all with the Python script (import pylink)

 

Any idea how to solve?

0 Kudos
Message 1 of 7
(4,525 Views)

Additional info:

I get the same error if I have a Hello World program which just does:

import ctypes

without further using it:

# HelloWorld.py

import ctypes

def hw():
    return "Hello World!"
   
if __name__ == "__main__":
    print hw()

0 Kudos
Message 2 of 7
(4,497 Views)

I Am getting desperate for a solution. I tried everything to my best knowledge with PYTHONPATH, PATH and serach directories in TestStand. Nothing works.

This issue with ctypes in Python Steps makes it uselss if not solvable.

 

Will try the more difficult way calling the script as 'Call Executable' with stdin and stdout.

Hopefully at least that works.

0 Kudos
Message 3 of 7
(4,488 Views)

Also Call Executable not working fro my purpose, as I can not keep the Python script open to get input to it after it generated some output on the first input.

It ends with EOL error and closes the script.

 

Any ideas?

0 Kudos
Message 4 of 7
(4,483 Views)
Solution
Accepted by topic author PythonAddict

I tried your hello world program (which imports ctypes) and it worked fine.

 

The following was my setup:

- TestStand 2017 64 bit

- Python 2.7 64 bit (downloaded and installed from https://www.python.org/)

- Enabled the option to update PATH environment variable when installing python 2.7

 

Are you using python interpreter from python.org? If not, can you try it again by installing python from https://www.python.org/?

 

-Shashidhar

Message 5 of 7
(4,482 Views)

Hi Shashidhar,

 

I am using 64 bit winpython and set the PATH variable to contain:

C:\WinPython\WinPython-64bit-2.7.10.3\python-2.7.10.amd64

C:\WinPython\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\Lib\site-packages\pywin32_system32

C:\WinPython\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\Lib\site-packages\pythonwin

C:\WinPython\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\Lib\site-packages

C:\WinPython\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\libs

 

I do not want to mess up with winpython, as I use it a lot for other stuff as well by intsalling something next to it.

Will see wether I can do it safely. Perhaps reinstall winpython first then.

 

 

 

 

 

0 Kudos
Message 6 of 7
(4,479 Views)

Great Shashidhar !!!

 

Installing from Python.org solved the problem, No ctypes issue anymore!

Not in Hello World program, but also not with pylink for the Segger J-Link.

re-installing winpython did not help.

It looks like winpython still runs ok for other stuff. But I certainly keep Python form python.org for TestStand.

0 Kudos
Message 7 of 7
(4,471 Views)