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

Import of LocalReadoutError from qiskit_experiments.library in IBM Quantum Lab #1050

Closed
DavidDaninOX opened this issue Feb 20, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@DavidDaninOX
Copy link

Informations

  • Qiskit Experiments version: 0.4
  • Python version: 3
  • Operating system: Windows 11

What is the current behavior?

When using from qiskit_experiments.library import LocalReadoutError in the IBM Quantum Lab, the error notification AttributeError: module 'sklearn.metrics._dist_metrics' has no attribute 'DistanceMetric32' is printed and the requested import does not happen.

Steps to reproduce the problem

Use 'from qiskit_experiments.library import LocalReadoutError' in IBM Quantum Lab.

What is the expected behavior?

Import of LocalReadoutError

Suggested solutions

@DavidDaninOX DavidDaninOX added the bug Something isn't working label Feb 20, 2023
@DavidDaninOX
Copy link
Author

Problem seems to exist for other applications using the scikit-learn package as well. Downgrading to scikit-learn 1.1.0 using the command pip install scikit-learn==1.1.0 in the IBM Quantum Lab resolved the issue

@wshanks wshanks added this to the Release 0.5 milestone Feb 27, 2023
@wshanks
Copy link
Collaborator

wshanks commented Feb 27, 2023

Hmm, while it seems like this is an issue outside of qiskit-experiments and has a workaround, I think we might want to address it by pushing the scikit-learn imports lower into the stack so that most users will not encounter them.

coruscating added a commit that referenced this issue Mar 3, 2023
### Summary

This commit pushes the import of scikit-learn lower into the code, so
that it does not occur until first usage.

### Details and comments

Previously, scikit-learn was in a `try` block which allowed for code
that did not use scikit-learn to work fine when it was not installed.
However, sometimes scikit-learn can be installed but have errors (like
in #1050) which were not caught by the `try` block. Further delaying the
import can help in this case. Additionally, scikit-learn is a little bit
of a slow import, so not importing it when it is not needed gives a
little bit of efficiency (maybe; mostly it imports scipy modules but
those might get imported any way by other analysis code).

---------

Co-authored-by: Helena Zhang <[email protected]>
@wshanks
Copy link
Collaborator

wshanks commented Mar 14, 2023

I removed the 0.5.0 milestone because #1061 was merged. I will leave this open until import qiskit_experiments works in the IBM Quantum Lab in case other users run into this problem and come looking here. This problem will be addressed in the next update to the IBM Quantum Lab which should happen very soon.

@wshanks wshanks removed this from the Release 0.5 milestone Mar 14, 2023
@wshanks
Copy link
Collaborator

wshanks commented Mar 16, 2023

import qiskit_experiments no longer produces an error in the Quantum Lab!

@wshanks wshanks closed this as completed Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants