admin管理员组文章数量:1346662
I'm working on a conda environment
This is the versions of my packages:
conda list qiskit
# packages in environment at /opt/anaconda3/envs/qnn:
#
# Name Version Build Channel
qiskit 2.0.0 py312hcd83bfe_0 conda-fe
qiskit-aer 0.17.0 pypi_0 pypi
qiskit-ibm-runtime 0.37.0 pypi_0 pypi
qiskit-machine-learning 0.8.2 pyhd8ed1ab_1 conda-fe
and when i try to import this:
import numpy as np
import pandas as pd
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
from qiskit.quantum_info import SparsePauliOp
from qiskit.primitives import StatevectorEstimator as Estimator
from qiskit_machine_learning.neural_networks import EstimatorQNN
I get this error in the last import:
ImportError:
----> 8 from qiskit_machine_learning.neural_networks import EstimatorQNN
[...]
File /opt/anaconda3/envs/qnn/lib/python3.12/site-packages/qiskit_machine_learning/neural_networks/effective_dimension.py:23
...
---> 24 from qiskit.primitives import BaseEstimator, BaseEstimatorV1, Estimator, EstimatorResult
25 from qiskit.quantum_info import SparsePauliOp
26 from qiskit.quantum_info.operators.base_operator import BaseOperator
ImportError: cannot import name 'BaseEstimator' from 'qiskit.primitives' (/opt/anaconda3/envs/qnn/lib/python3.12/site-packages/qiskit/primitives/__init__.py)
If i try to do this:
from qiskit.primitives import Estimator
I get
ImportError: cannot import name 'Estimator' from 'qiskit.primitives' (/opt/anaconda3/envs/qnn/lib/python3.12/site-packages/qiskit/primitives/__init__.py)
I know it's because qiskit 2.0.0 it's not compatible with qiskit-machine-learning 0.8.2.
So first, i tried to downgrade to qiskit 0.44.0, didn't resolve.
Then i tried update qiskit-machine-learning to 0.9.0 and couldn't because anaconda...
conda install -c conda-fe qiskit-machine-learning=0.9.0
Channels:
- conda-fe
- defaults
Platform: osx-arm64
Collecting package metadata (repodata.json): done
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
- qiskit-machine-learning=0.9.0*
Can anyone tell me how can i fix this?
I'm working on a conda environment
This is the versions of my packages:
conda list qiskit
# packages in environment at /opt/anaconda3/envs/qnn:
#
# Name Version Build Channel
qiskit 2.0.0 py312hcd83bfe_0 conda-fe
qiskit-aer 0.17.0 pypi_0 pypi
qiskit-ibm-runtime 0.37.0 pypi_0 pypi
qiskit-machine-learning 0.8.2 pyhd8ed1ab_1 conda-fe
and when i try to import this:
import numpy as np
import pandas as pd
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
from qiskit.quantum_info import SparsePauliOp
from qiskit.primitives import StatevectorEstimator as Estimator
from qiskit_machine_learning.neural_networks import EstimatorQNN
I get this error in the last import:
ImportError:
----> 8 from qiskit_machine_learning.neural_networks import EstimatorQNN
[...]
File /opt/anaconda3/envs/qnn/lib/python3.12/site-packages/qiskit_machine_learning/neural_networks/effective_dimension.py:23
...
---> 24 from qiskit.primitives import BaseEstimator, BaseEstimatorV1, Estimator, EstimatorResult
25 from qiskit.quantum_info import SparsePauliOp
26 from qiskit.quantum_info.operators.base_operator import BaseOperator
ImportError: cannot import name 'BaseEstimator' from 'qiskit.primitives' (/opt/anaconda3/envs/qnn/lib/python3.12/site-packages/qiskit/primitives/__init__.py)
If i try to do this:
from qiskit.primitives import Estimator
I get
ImportError: cannot import name 'Estimator' from 'qiskit.primitives' (/opt/anaconda3/envs/qnn/lib/python3.12/site-packages/qiskit/primitives/__init__.py)
I know it's because qiskit 2.0.0 it's not compatible with qiskit-machine-learning 0.8.2.
So first, i tried to downgrade to qiskit 0.44.0, didn't resolve.
Then i tried update qiskit-machine-learning to 0.9.0 and couldn't because anaconda...
conda install -c conda-fe qiskit-machine-learning=0.9.0
Channels:
- conda-fe
- defaults
Platform: osx-arm64
Collecting package metadata (repodata.json): done
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
- qiskit-machine-learning=0.9.0*
Can anyone tell me how can i fix this?
Share Improve this question edited 2 days ago diogomaia00 asked 2 days ago diogomaia00diogomaia00 12 bronze badges New contributor diogomaia00 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.1 Answer
Reset to default 0Qiskit Machine Learning 0.9.0 has not been released. Its still work in progress and does not support Qiskit 2.0 either. Qiskit 0.44 is too old. The requirements need >1.0 see https://github/qiskit-community/qiskit-machine-learning/blob/0a114922a93b6b8921529ada886fe9be08f163b2/requirements.txt#L1 for this (that's on the 0.8 branch and on main its been pinned to <2.0 as well at present). Try installing the latest version prior to 2.0 i.e Qiskit 1.4.2 which should have things working for you.
本文标签: condaImport Error cannot import name 39BaseEstimator39 from 39qiskitprimitives39Stack Overflow
版权声明:本文标题:conda - Import Error: cannot import name 'BaseEstimator' from 'qiskit.primitives' - Stack Overfl 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743825938a2545639.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论