NI TestStand

取消
显示结果 
搜索替代 
您的意思是: 

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

已解决!
转到解答

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 项奖励
1 条消息(共 7 条)
4,857 次查看

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 项奖励
2 条消息(共 7 条)
4,829 次查看

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 项奖励
3 条消息(共 7 条)
4,820 次查看

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 项奖励
4 条消息(共 7 条)
4,815 次查看
解答
已被主题作者 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

5 条消息(共 7 条)
4,814 次查看

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 项奖励
6 条消息(共 7 条)
4,811 次查看

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 项奖励
7 条消息(共 7 条)
4,803 次查看