Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DLL load failed while importing ziPython #51

Open
davguy opened this issue Oct 9, 2022 · 5 comments
Open

DLL load failed while importing ziPython #51

davguy opened this issue Oct 9, 2022 · 5 comments

Comments

@davguy
Copy link

davguy commented Oct 9, 2022

Dear Zurich Instruments,

I am not able to import zhinst-qcodes.
This is the computer set-up:
Anaconda
Python 3.10.6
Windows 10

The minimal code to reproduce it for me is:
import zhinst.qcodes
Do you know how I can fix this?
All other package import work, including zhinst.
The traceback given is:

ImportError                               Traceback (most recent call last)
Cell In [5], line 1
----> 1 import zhinst.qcodes

File ~\Anaconda3\envs\SSNL\lib\site-packages\zhinst\qcodes\__init__.py:1
----> 1 from zhinst.qcodes.control.drivers import *

File ~\Anaconda3\envs\SSNL\lib\site-packages\zhinst\qcodes\control\drivers\__init__.py:1
----> 1 from .hdawg import HDAWG
      2 from .uhfqa import UHFQA
      3 from .uhfli import UHFLI

File ~\Anaconda3\envs\SSNL\lib\site-packages\zhinst\qcodes\control\drivers\hdawg.py:1
----> 1 from .base import ZIBaseInstrument
      2 import zhinst.toolkit as tk
      3 from zhinst.toolkit.control.drivers.hdawg import AWG as HDAWG_AWG

File ~\Anaconda3\envs\SSNL\lib\site-packages\zhinst\qcodes\control\drivers\base\__init__.py:1
----> 1 from .base import ZIBaseInstrument

File ~\Anaconda3\envs\SSNL\lib\site-packages\zhinst\qcodes\control\drivers\base\base.py:7
      5 from qcodes.instrument.channel import ChannelList, InstrumentChannel
      6 from qcodes.utils.validators import ComplexNumbers
----> 7 import zhinst.toolkit as tk
      8 from typing import List, Dict
     11 class ZIQcodesException(Exception):

File ~\Anaconda3\envs\SSNL\lib\site-packages\zhinst\toolkit\__init__.py:17
      1 # Copyright (C) 2020 Zurich Instruments
      2 #
      3 # This software may be modified and distributed under the terms
      4 # of the MIT license. See the LICENSE file for details.
      5 """The Zurich Instruments Toolkit (zhinst-toolkit)
      6 
      7 This package is a collection of Python tools for high level device
   (...)
     14 Labber. It comes in the form of a package compatible with Python 3.6+.
     15 """
---> 17 from zhinst.toolkit.control.drivers import (
     18     BaseInstrument,
     19     HDAWG,
     20     UHFQA,
     21     UHFLI,
     22     MFLI,
     23     PQSC,
     24     SHFQA,
     25     SHFSG,
     26 )
     27 from zhinst.toolkit.interface import DeviceTypes
     28 from zhinst.toolkit.control.multi_device_connection import MultiDeviceConnection

File ~\Anaconda3\envs\SSNL\lib\site-packages\zhinst\toolkit\control\drivers\__init__.py:10
      1 # Copyright (C) 2020 Zurich Instruments
      2 #
      3 # This software may be modified and distributed under the terms
      4 # of the MIT license. See the LICENSE file for details.
      5 """The Zurich Instruments Toolkit (zhinst-toolkit) Drivers
      6 
      7 This package is a collection of high level controllers for Zurich
      8 Instruments devices.
      9 """
---> 10 from .base import BaseInstrument
     11 from .hdawg import HDAWG
     12 from .uhfqa import UHFQA

File ~\Anaconda3\envs\SSNL\lib\site-packages\zhinst\toolkit\control\drivers\base\__init__.py:1
----> 1 from .awg import AWGCore
      2 from .scope import Scope
      3 from .shf_qachannel import SHFQAChannel

File ~\Anaconda3\envs\SSNL\lib\site-packages\zhinst\toolkit\control\drivers\base\awg.py:14
     12 from zhinst.toolkit.helpers import SequenceProgram, Waveform, SequenceType, TriggerMode
     13 from zhinst.toolkit.interface.interface import DeviceTypes
---> 14 from .base import BaseInstrument
     15 from zhinst.toolkit.interface import LoggerModule
     16 from ...parsers import Parse

File ~\Anaconda3\envs\SSNL\lib\site-packages\zhinst\toolkit\control\drivers\base\base.py:15
     13 from typing import Dict
     14 import time
---> 15 import zhinst.ziPython as zi
     17 from zhinst.toolkit.control.connection import DeviceConnection, ZIConnection
     18 from zhinst.toolkit.control.node_tree import NodeTree

ImportError: DLL load failed while importing ziPython: The specified module could not be found.
@tobiasah
Copy link
Member

@davguy thank you for reporting this. We indeed already had similar reports and are working on a solution.

I have a couple of questions.

  1. Which exact python package versions are you using?
  2. Which exact Windows version (e.g. using exec -> winver)?
  3. What do you mean by all other zhinst imports work?

@davguy
Copy link
Author

davguy commented Oct 10, 2022

Hi Tobias, thanks for your quick response!

  1. I'm using version 0.2.2 of zhinst-qcodes, version 21.8.20515 of zhinst.
  2. Windows 10, version 1607 (OS build 14393.5246)
  3. I meant that I can import all other python modules, like numpy, scipy, etc. Also including the regular zhinst package.

On closer look, I also can't import zhinst-toolkit:

>>> import zhinst.toolkit
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\TUD208555\Anaconda3\envs\SSNL\lib\site-packages\zhinst\toolkit\__init__.py", line 18, in <module>
    from zhinst.toolkit.session import PollFlags, Session
  File "C:\Users\TUD208555\Anaconda3\envs\SSNL\lib\site-packages\zhinst\toolkit\session.py", line 9, in <module>
    import zhinst.toolkit.driver.devices as tk_devices
  File "C:\Users\TUD208555\Anaconda3\envs\SSNL\lib\site-packages\zhinst\toolkit\driver\devices\__init__.py", line 4, in <module>
    from zhinst.toolkit.driver.devices.base import BaseInstrument
  File "C:\Users\TUD208555\Anaconda3\envs\SSNL\lib\site-packages\zhinst\toolkit\driver\devices\base.py", line 16, in <module>
    from zhinst.core import __version__ as zhinst_version_str
ImportError: DLL load failed while importing core: The specified procedure could not be found.
```python

@tobiasah
Copy link
Member

Thanks for the additional information. They seem to confirm my hunch that it is related to a known issue.

The problem probably is that we (by mistake) are using a c++ library function in the LabOne Client code that is only support on the latest Windows 10 versions. We already have removed this function call and planing to make a patch release for LabOne 22.08 within 1 to 2 weeks.

In the meantime, you either can fallback to LabOne 22.02 or checking if updating your Windows 10 to the latest update solves this issue for you.

Sorry for the inconvenience!

@davguy
Copy link
Author

davguy commented Oct 11, 2022

Hi I did both, but it still didn't work. It seems to go wrong with the __init__pyi file in zhinst/core. Any import from there seems to fail. I now just made it a .py file and changed version. So now I can at least import the thing haha.

@tobiasah
Copy link
Member

Renaming the .pyi file will do you no good. It is just the interface file which is not used by python itself but only by the typehinter/checker. The logic is completely within the core.so file. Renaming the .pyi file to .py will just prevent python to use the binary and therefor remove any logic.

When you downgraded to 22.02 did you uninstall all zhinst packages (zhinst, zhinst-core, zhinst-toolkit, zhinst-qcodes and reinstalled zhinst==22.2.29711 from scratch? The bug is within the .so file so only uninstalling and reinstalling will solve that.
Also, when updating your Windows install, you must uninstall and reinstall all zhinst-packages.

So I would recommend the following:

  • pip uninstall zhinst zhinst-core zhinst-toolkit zhinst-qcodes
  • manually delete the zhinst folder in the sitepackages folder of your python enviroment (probably needed since you manually added (renamed) a file

Either try:

pip install zhinst==22.2.29711

(for using the old LabOne until the patch) or

pip install zhinst

for trying it again after the windows update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants