national instruments pyDAQmx for python 3

1.2k views Asked by At

Python 3.7

I am writing a Python (3.7) code for National Instruments hardware. There is a python library for Python 2.7. There are instructions on how to convert the library to be with Python 3.

  1. I have downloaded PyDAQmx-1.4.1.tar.gz from the project website
  2. extracted the content of the archive file to a directory
  3. go to that directory in the terminal
  4. to convert PyDAQmx library from 2 to 3, I run the 2to3 converter in the terminal following instruction.

C:\Downloads\>2to3 --output-dir=PyDAQmx-1.4.1-3 -W -n PyDAQmx-1.4.1 >2to3.log 2>&1

You can inspect the log file for error and warnings.

next,build

C:\Downloads\PyDAQmx-1.4.1-3>py setup.py build >build 2>&1 and install

and install

C:\Downloads\PyDAQmx-1.4.1-3>py setup.py install >install.log 2> &1

this should create an egg file in the Python 3 directory. And yes indeed there is a file -> PyDAQmx-1.4.1-py3.7.egg

The first time you will try to import the PyDAQmx library in Python 3 the egg file will be unzipped and you get PyDAQmx subdirectory in the site-packages folder.

C:\Python37-32\Lib\PyDAQmx-1.4.1>py
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Inte
l)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyDAQmx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python37-32\Lib\PyDAQmx-1.4.1\PyDAQmx\__init__.py", line 3, in <modul
e>
    import DAQmxConfig
ModuleNotFoundError: No module named 'DAQmxConfig'
>>>

there is DAQmxConfig file in a subdirectory.

why didn't it work? and is there a better protocol than what is available on the PyDAQmx website

1

There are 1 answers

0
Valentyn On BEST ANSWER

Here is the solution:

follow the protocol posted on the webpage

Briefly,

  1. download PyDAQmx-1.4.1.tar.gz from the project website
  2. extract the content of the archive file to a directory
  3. go to that directory in the terminal
  4. to convert PyDAQmx library from 2 to 3, I run the 2to3 converter in the terminal following instruction.

C:\Downloads\>2to3 --output-dir=PyDAQmx-1.4.1-3 -W -n PyDAQmx-1.4.1 >2to3.log 2>&1

You can inspect the log file for error and warnings.

next, build

C:\Downloads\PyDAQmx-1.4.1-3>py setup.py build >build 2>&1 and install

if you install you indeed get an egg file but there is a corrupted file.

C:\Downloads\PyDAQmx-1.4.1-3>py setup.py install >install.log 2> &1

the DAQmxCallBack file is corrupted enter image description here

you need to go to \PyDAQmx-1.4.1-3 folder which you got after the conversion from 2 to 3 and copy the file DAQmxCallBack file from the \PyDAQmx\ subdirectory to site-packages subdirectory of Python 3 installation.

Another way would be to skip the install command and just directly copy PyDAQmx folder from \PyDAQmx-1.4.1-3 to C:\Python37-32\Lib\site-packages (or wherever you have you python3 installed)