简体   繁体   中英

DLL load failed while importing _tweedledum

I need to use Qiskit library, but I have issue with importing qiskit itself.

I have Python 3.8.10 installed on Windiws 10

While I run import, I have follow error:

c:\repos\quantml>py -0
Installed Pythons found by py Launcher for Windows
 -3.8-64 *


c:\repos\quantml>py
Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import qiskit
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\psheom\AppData\Local\Programs\Python\Python38\lib\site-packages\qiskit\__init__.py", line 25, in <module>
    from qiskit.circuit import ClassicalRegister
  File "C:\Users\psheom\AppData\Local\Programs\Python\Python38\lib\site-packages\qiskit\circuit\__init__.py", line 244, in <module>
    from .classicalfunction.types import Int1, Int2
  File "C:\Users\psheom\AppData\Local\Programs\Python\Python38\lib\site-packages\qiskit\circuit\classicalfunction\__init__.py", line 98, in <module>
    from .classicalfunction import ClassicalFunction
  File "C:\Users\psheom\AppData\Local\Programs\Python\Python38\lib\site-packages\qiskit\circuit\classicalfunction\classicalfunction.py", line 18, in <module>
    from tweedledum.classical import simulate
  File "C:\Users\psheom\AppData\Local\Programs\Python\Python38\lib\site-packages\tweedledum\__init__.py", line 5, in <module>
    from ._tweedledum import *
ImportError: DLL load failed while importing _tweedledum: Не найден указанный модуль.
>>> ^Z

This is log of pip install :

Collecting qiskit
  Using cached qiskit-0.34.1.tar.gz (13 kB)
  Preparing metadata (setup.py) ... done
Collecting qiskit-terra==0.19.1
  Downloading qiskit_terra-0.19.1-cp38-cp38-win_amd64.whl (5.6 MB)
     ---------------------------------------- 5.6/5.6 MB 13.8 MB/s eta 0:00:00
Collecting qiskit-aer==0.10.2
  Downloading qiskit_aer-0.10.2-cp38-cp38-win_amd64.whl (24.2 MB)
     ---------------------------------------- 24.2/24.2 MB 43.6 MB/s eta 0:00:00
Collecting qiskit-ibmq-provider==0.18.3
  Using cached qiskit_ibmq_provider-0.18.3-py3-none-any.whl (238 kB)
Collecting qiskit-ignis==0.7.0
  Using cached qiskit_ignis-0.7.0-py3-none-any.whl (200 kB)
Requirement already satisfied: scipy>=1.0 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from qiskit-aer==0.10.2->qiskit) (1.7.3)
Requirement already satisfied: numpy>=1.16.3 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from qiskit-aer==0.10.2->qiskit) (1.22.1)
Requirement already satisfied: requests>=2.19 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from qiskit-ibmq-provider==0.18.3->qiskit) (2.27.1)
Requirement already satisfied: urllib3>=1.21.1 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from qiskit-ibmq-provider==0.18.3->qiskit) (1.26.8)
Requirement already satisfied: websocket-client>=1.0.1 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from qiskit-ibmq-provider==0.18.3->qiskit) (1.2.3)
Requirement already satisfied: python-dateutil>=2.8.0 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from qiskit-ibmq-provider==0.18.3->qiskit) (2.8.2)
Collecting requests-ntlm>=1.1.0
  Using cached requests_ntlm-1.1.0-py2.py3-none-any.whl (5.7 kB)
Requirement already satisfied: setuptools>=40.1.0 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from qiskit-ignis==0.7.0->qiskit) (56.0.0)
Collecting retworkx>=0.8.0
  Downloading retworkx-0.11.0-cp38-cp38-win_amd64.whl (1.2 MB)
     ---------------------------------------- 1.2/1.2 MB 37.5 MB/s eta 0:00:00
Collecting stevedore>=3.0.0
  Using cached stevedore-3.5.0-py3-none-any.whl (49 kB)
Collecting tweedledum<2.0,>=1.1
  Downloading tweedledum-1.1.1-cp38-cp38-win_amd64.whl (1.1 MB)
     ---------------------------------------- 1.1/1.1 MB 66.1 MB/s eta 0:00:00
Collecting ply>=3.10
  Using cached ply-3.11-py2.py3-none-any.whl (49 kB)
Collecting psutil>=5
  Downloading psutil-5.9.0-cp38-cp38-win_amd64.whl (246 kB)
     ---------------------------------------- 246.5/246.5 KB ? eta 0:00:00
Collecting sympy>=1.3
  Using cached sympy-1.9-py3-none-any.whl (6.2 MB)
Collecting dill>=0.3
  Using cached dill-0.3.4-py2.py3-none-any.whl (86 kB)
Collecting python-constraint>=1.4
  Using cached python-constraint-1.4.0.tar.bz2 (18 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: six>=1.5 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from python-dateutil>=2.8.0->qiskit-ibmq-provider==0.18.3->qiskit) (1.16.0)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from requests>=2.19->qiskit-ibmq-provider==0.18.3->qiskit) (2021.10.8)
Requirement already satisfied: charset-normalizer~=2.0.0 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from requests>=2.19->qiskit-ibmq-provider==0.18.3->qiskit) (2.0.11)
Requirement already satisfied: idna<4,>=2.5 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from requests>=2.19->qiskit-ibmq-provider==0.18.3->qiskit) (2.10)
Collecting cryptography>=1.3
  Using cached cryptography-36.0.1-cp36-abi3-win_amd64.whl (2.2 MB)
Collecting ntlm-auth>=1.0.2
  Using cached ntlm_auth-1.5.0-py2.py3-none-any.whl (29 kB)
Collecting pbr!=2.1.0,>=2.0.0
  Using cached pbr-5.8.0-py2.py3-none-any.whl (112 kB)
Collecting mpmath>=0.19
  Using cached mpmath-1.2.1-py3-none-any.whl (532 kB)
Requirement already satisfied: cffi>=1.12 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from cryptography>=1.3->requests-ntlm>=1.1.0->qiskit-ibmq-provider==0.18.3->qiskit) (1.15.0)
Requirement already satisfied: pycparser in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from cffi>=1.12->cryptography>=1.3->requests-ntlm>=1.1.0->qiskit-ibmq-provider==0.18.3->qiskit) (2.21)
Building wheels for collected packages: qiskit, python-constraint
  Building wheel for qiskit (setup.py) ... done
  Created wheel for qiskit: filename=qiskit-0.34.1-py3-none-any.whl size=11754 sha256=e9b4a0e9fc197867c9f52eb6258afe2938de7d67824ffd71fc21ade5e7a0b387
  Stored in directory: c:\users\psheom\appdata\local\pip\cache\wheels\9f\f8\19\dacc191256a3d7dc26aec784e0293340351285b7123d23703d
  Building wheel for python-constraint (setup.py) ... done
  Created wheel for python-constraint: filename=python_constraint-1.4.0-py2.py3-none-any.whl size=24081 sha256=4658eabe616621c3e0fdfcacd5ce5c3f557f1106c2ed0bc044a6d5ef503e26b1
  Stored in directory: c:\users\psheom\appdata\local\pip\cache\wheels\86\ba\5c\4e9115777de42c6a2e1ca77ef7c9d0d479254c5080341b55c5
Successfully built qiskit python-constraint
Installing collected packages: python-constraint, ply, mpmath, tweedledum, sympy, retworkx, psutil, pbr, ntlm-auth, dill, stevedore, cryptography, requests-ntlm, qiskit-terra, qiskit-ignis, qiskit-ibmq-provider, qiskit-aer, qiskit
Successfully installed cryptography-36.0.1 dill-0.3.4 mpmath-1.2.1 ntlm-auth-1.5.0 pbr-5.8.0 ply-3.11 psutil-5.9.0 python-constraint-1.4.0 qiskit-0.34.1 qiskit-aer-0.10.2 qiskit-ibmq-provider-0.18.3 qiskit-ignis-0.7.0 qiskit-terra-0.19.1 requests-ntlm-1.1.0 retworkx-0.11.0 stevedore-3.5.0 sympy-1.9 tweedledum-1.1.1
Collecting matplotlib
  Downloading matplotlib-3.5.1-cp38-cp38-win_amd64.whl (7.2 MB)
     ---------------------------------------- 7.2/7.2 MB 17.1 MB/s eta 0:00:00
Collecting pillow>=6.2.0
  Downloading Pillow-9.0.0-cp38-cp38-win_amd64.whl (3.2 MB)
     ---------------------------------------- 3.2/3.2 MB 34.1 MB/s eta 0:00:00
Requirement already satisfied: pyparsing>=2.2.1 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from matplotlib) (3.0.7)
Collecting fonttools>=4.22.0
  Downloading fonttools-4.29.0-py3-none-any.whl (895 kB)
     ---------------------------------------- 895.0/895.0 KB 55.3 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.17 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from matplotlib) (1.22.1)
Collecting kiwisolver>=1.0.1
  Downloading kiwisolver-1.3.2-cp38-cp38-win_amd64.whl (52 kB)
     ---------------------------------------- 52.1/52.1 KB ? eta 0:00:00
Collecting cycler>=0.10
  Using cached cycler-0.11.0-py3-none-any.whl (6.4 kB)
Requirement already satisfied: packaging>=20.0 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from matplotlib) (21.3)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from matplotlib) (2.8.2)
Requirement already satisfied: six>=1.5 in c:\users\psheom\appdata\local\programs\python\python38\lib\site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)
Installing collected packages: pillow, kiwisolver, fonttools, cycler, matplotlib
Successfully installed cycler-0.11.0 fonttools-4.29.0 kiwisolver-1.3.2 matplotlib-3.5.1 pillow-9.0.0

OK, so I solved the issue, and here is the path for solution.

This is a common way to solve python DLL load issues.

The problem was with windows DLLs.

Way to the solution

First of all I located the path to module's library from the error, in my case it is: C:\Users\olga\AppData\Local\Programs\Python\Python38\lib\site-packages\tweedledum

I found there only one binary file, I tried to change it name, and give the original name back. While the change I ran the import and detected the error differs:

Rename to _tweedledum.cp38-win_amd64.pyd :

在此处输入图像描述

Rename back to _tweedledum.cp39-win_amd64.pyd :

在此处输入图像描述

So we can be sure, that there is some requirement for some DLL.

I downloaded lucasg-Dependencies and opened the python binary:

在此处输入图像描述

You can see that MSVCP140_CODECVT_IDS.dll is missing.

Than I opened the same file on the workstation where the import qiskit worked fine and saw:

在此处输入图像描述

I copied the file directly to the tweedledum folder:

在此处输入图像描述

and than run the import again (you supposed to rerun the python session):

在此处输入图像描述

As you can see, everything works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM