“qiskit_nature”中的”units”子模块去哪了?

huangapple go评论57阅读模式
英文:

Where has the "units" sub-module in qiskit_nature gone?

问题

我正在尝试按照qiskit "Electronic Structure"教程进行操作,但在第一步设置PySCF驱动程序时出现了以下错误:

  1. from qiskit_nature.units import DistanceUnit
  2. from qiskit_nature.second_q.drivers import PySCFDriver
  3. driver = PySCFDriver(
  4. atom="H 0 0 0; H 0 0 0.735",
  5. basis="sto3g",
  6. charge=0,
  7. spin=0,
  8. unit=DistanceUnit.ANGSTROM,
  9. )

错误提示找不到qiskit_nature中的"units"模块。

我已经使用pip(pip3,Python 3.6)安装了qiskit_nature,并且当我列出qiskit_nature的子模块时,我得到以下结果:

  1. algorithms
  2. circuit
  3. constants
  4. converters
  5. deprecation
  6. drivers
  7. exceptions
  8. mappers
  9. operators
  10. problems
  11. properties
  12. results
  13. runtime
  14. settings
  15. transformers
  16. version

我检查了大多数内容,似乎没有任何"units"模块。虽然上面的子模块调用可能是微不足道的,或者可以规避,但是这个子模块去哪了?它是否因为将"qiskit.chemistry"迁移到"nature"时重新组织了内容而丢失了?如果是这样,为什么"nature"模块上的教程没有反映这一点呢?

【注意】:这是您要翻译的内容。

英文:

I am trying to follow this qiskit "Electronic Structure" tutorial, but at the very first step, setting up the PySCF driver with the following

  1. from qiskit_nature.units import DistanceUnit
  2. from qiskit_nature.second_q.drivers import PySCFDriver
  3. driver = PySCFDriver(
  4. atom="H 0 0 0; H 0 0 0.735",
  5. basis="sto3g",
  6. charge=0,
  7. spin=0,
  8. unit=DistanceUnit.ANGSTROM,
  9. )

produces an error. The error says there is no module "units" in qiskit_nature.

I have installed qiskit_nature with pip (pip3, python 3.6) and when I listed the submodules of qiskit_nature I get

  1. algorithms
  2. circuit
  3. constants
  4. converters
  5. deprecation
  6. drivers
  7. exceptions
  8. mappers
  9. operators
  10. problems
  11. properties
  12. results
  13. runtime
  14. settings
  15. transformers
  16. version

I checked most and there appears not to be a "units" module anywhere. While the call to the submodule "units" in the above may be trivial and/or circumvented, where has the submodule gone? Is it missing because when they ported the "qiskit.chemistry" to "nature" they re-organised things? If so, why do the tutorials on the "nature" module not reflect this?

答案1

得分: 0

units.py模块位于Qiskit Nature的根目录中。没有名为units的包/文件夹/子模块,它是一个单独的文件。

英文:

The module units.py is there in Qiskit Nature in the root. There is no package/folder/submodule called units. Its a single file.

答案2

得分: 0

  1. pip install --upgrade qiskit_nature
  2. maybe work around it, replace the import statement from qiskit_nature.units import DistanceUnit with qiskit_nature.units._units
英文:

pip install --upgrade qiskit_nature

maybe work around it, replace the import statement from qiskit_nature.units import DistanceUnit with qiskit_nature.units._units

答案3

得分: 0

我假设您正在尝试运行最新的教程,但您没有安装最新版本的Qiskit Nature。这基于以下三点观察:

  1. 缺少units模块,该模块仅在Qiskit Nature v0.5.0中添加。
  2. 也缺少second_q模块,该模块也在该版本中添加。
  3. 此外,您说您正在使用Python 3.6,但在版本0.4.0中已删除对该版本的支持。

因此,我强烈推测您安装了Qiskit Nature v0.3.2,这是pip在该Python版本下应该解析到的最后一个发布版本。

现在,您如何解决这个问题:我强烈建议您首先切换到更新的Python版本。3.6版本已于2021年12月23日到达了其生命周期的终点1
我建议您升级到Python 3.9,它将在2025年之前得到支持,并且已在所有平台上进行了“战斗测试”。

一旦您升级了Python版本,您将需要重新安装Qiskit Nature:

  1. pip3 install --upgrade qiskit-nature
英文:

I am assuming that you are trying to run the latest tutorial but you do not have the latest version of Qiskit Nature installed. This is based on three observatons:

  1. The units module is missing which only got added in Qiskit Nature v0.5.0
  2. The second_q module is missing, too, which also got added in that version.
  3. Furthermore, you say that you are using Python 3.6, support which has been removed in version 0.4.0.

Thus, I strongly assume you installed Qiskit Nature v0.3.2 which is the last release that pip should resolve to under that Python version.

Now, how do you go about solving this problem: I strongly suggest that you first switch to a newer Python version. 3.6 has reached its end of life on Dec 23rd, 2021 1.
I suggest you upgrade to Python 3.9 which will be supported into 2025 and has already been "battle-tested" on all platforms.

Once you have upgrade your Python version, you will need to re-install Qiskit Nature:

  1. pip3 install --upgrade qiskit-nature

huangapple
  • 本文由 发表于 2023年5月25日 03:01:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76326665.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定