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

ModuleNotFoundError: No module named 'qiskit.extensions' #333

Closed
quantumomega opened this issue Feb 24, 2024 · 4 comments
Closed

ModuleNotFoundError: No module named 'qiskit.extensions' #333

quantumomega opened this issue Feb 24, 2024 · 4 comments

Comments

@quantumomega
Copy link

quantumomega commented Feb 24, 2024

Environment

  • Qiskit Finance version: 0.5.0
  • Python version: Using the Qiskit Lab v1.0.0
  • Operating system: Windows 11

What is happening?

Hi, technically I am new to this quantum computing stuff.
I see that an upgrade of Qiskit to 1.0 was made, and that this pretty much removed the qiskit.extensions.
However, in the Qiskit_finance repository trying to make the tutorial, they say it runs even for this new version of Qiskit.

I am trying with tutorial 09_credit_risk_analysis.ipynb but in this part:
from qiskit_finance.circuit.library import GaussianConditionalIndependenceModel as GCI.

u = GCI(n_z, z_max, p_zeros, rhos)

I get the error in the title.
Is there something I need to install?

How can we reproduce the issue?

Trying to run:

from qiskit_finance.circuit.library import GaussianConditionalIndependenceModel as GCI

u = GCI(n_z, z_max, p_zeros, rhos)

What should happen?

It should extract a Gaussian function previously located in qiskit_finance.circuit.library

Any suggestions?

No response

@edoaltamura
Copy link
Contributor

Hi @quantumomega, Qiskit finance doesn't have a qiskit.extensions dependency as far as I could find. Does the error persist after restarting the Qiskit Lab kernel? Could you please provide the exact values you assigned to the variables n_z, z_max, p_zeros, rhos?

I ruled out an issue related to the recent Qiskit 1.0.0 update by checking that your code snippet runs with the following modules

qiskit                        1.0.1
qiskit-aer                    0.13.3
qiskit-algorithms             0.3.0
qiskit-optimization           0.6.0

@quantumomega
Copy link
Author

quantumomega commented Feb 24, 2024

Hi @quantumomega, Qiskit finance doesn't have a qiskit.extensions dependency as far as I could find. Does the error persist after restarting the Qiskit Lab kernel? Could you please provide the exact values you assigned to the variables n_z, z_max, p_zeros, rhos?

I ruled out an issue related to the recent Qiskit 1.0.0 update by checking that your code snippet runs with the following modules

qiskit                        1.0.1
qiskit-aer                    0.13.3
qiskit-algorithms             0.3.0
qiskit-optimization           0.6.0

Hi, @edoaltamura, I am sharing the excerpt from the program I am trying to run along with the error it is throwing. I have already tried resetting the kernel, but the issue persists. I do not understand why it mentions Qiskit.extensions.

Git_Qiskit

Additionally, I'm including the code in text format so that it can be replicated. This code is from the tutorial shown in the Qiskit Finance GitHub repository.

import numpy as np
import matplotlib.pyplot as plt

from qiskit import QuantumRegister, QuantumCircuit
from qiskit.circuit.library import IntegerComparator
from qiskit_algorithms import IterativeAmplitudeEstimation, EstimationProblem
from qiskit_aer.primitives import SamplerS
#set problem parameters
n_z = 2
z_max = 2
z_values = np.linspace(-z_max, z_max, 2**n_z)
p_zeros = [0.15, 0.25]
rhos = [0.1, 0.05]
lgd = [1, 2]
K = len(p_zeros)
alpha = 0.05
from qiskit_finance.circuit.library import GaussianConditionalIndependenceModel as GCI
u = GCI(n_z, z_max, p_zeros, rhos)

Greetings.

@woodsp-ibm
Copy link
Member

woodsp-ibm commented Feb 24, 2024

@quantumomega I assume that was your stackoverflow question similar to this issue. I answered that earlier not having seen this.

As I stated in that answer, there are fixes done here, for compatibility with Qiskit 1.0, such as #317, which have been backported to stable in preparation an official release but that still needs to happen. The tutorials got republished as docs were needed to be updated and they also had to be fixed #331 so they do show 1.0 in them but they have been run using the code in this repo, which as I say has yet to be released. Until then you can either install from source here or downgrade to Qiskit 0.46 (maybe 0.45), both suggestions as per the response there

@woodsp-ibm
Copy link
Member

@quantumomega Qiskit Finance 0.4.1 was just released which has the compatibility fixes in it for Qiskit 1.0. So if you upgrade to that now you can use Qiskit 1.0 with tutorial that previously, as above you had problems with. I am going to close this on the basis it all should work now for you as it does in CI here.

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

3 participants