‘_cext’ – 导入OrbitalPy时找不到此模块

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

'_cext' - no such module when importing OrbitalPy

问题

我在Python中使用OrbitalPy库来显示轨道。

然而,当我运行程序(实际上是在OrbitalPy的文档/示例中列出的)时,我收到了以下错误:

from numpy import radians
from scipy.constants import kilo

from orbital import earth, KeplerianElements, Maneuver, plot, plot3d

from orbital import earth_sidereal_day
molniya = KeplerianElements.with_period(
    earth_sidereal_day / 2, e=0.741, i=radians(63.4), arg_pe=radians(270),
    body=earth)

plot3d(molniya)

我得到了以下错误:

C:\Users\xxx\Desktop>py molniya.py
Traceback (most recent call last):
  File "C:\Users\xxx\Desktop\molniya.py", line 4, in <module>
    from orbital import earth, KeplerianElements, Maneuver, plot, plot3d
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\orbital\__init__.py", line 8, in <module>
    from .plotting import *
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\orbital\plotting.py", line 9, in <module>
    import matplotlib as mpl
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\__init__.py", line 246, in <module>
    _check_versions()
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\__init__.py", line 240, in _check_versions
    module = importlib.import_module(modname)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\kiwisolver\__init__.py", line 8, in <module>
    from ._cext import (
ImportError: DLL load failed while importing _cext: The specified module could not be found.

我已经尝试重新安装matplotlib和kiwisolver,但没有帮助。甚至在谷歌搜索中也没有找到关于这个问题的任何结果。

英文:

I'm using the OrbitalPy lib to display orbits in Python.

However, when I run the program (which is actually listed in the docs/examples of OrbitalPy):

from numpy import radians
from scipy.constants import kilo

from orbital import earth, KeplerianElements, Maneuver, plot, plot3d

from orbital import earth_sidereal_day
molniya = KeplerianElements.with_period(
    earth_sidereal_day / 2, e=0.741, i=radians(63.4), arg_pe=radians(270),
    body=earth)

plot3d(molniya)

I get the following errors:

C:\Users\xxx\Desktop&gt;py molniya.py
Traceback (most recent call last):
  File &quot;C:\Users\xxx\Desktop\molniya.py&quot;, line 4, in &lt;module&gt;
    from orbital import earth, KeplerianElements, Maneuver, plot, plot3d
  File &quot;C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\orbital\__init__.py&quot;, line 8, in &lt;module&gt;
    from .plotting import *
  File &quot;C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\orbital\plotting.py&quot;, line 9, in &lt;module&gt;
    import matplotlib as mpl
  File &quot;C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\__init__.py&quot;, line 246, in &lt;module&gt;
    _check_versions()
  File &quot;C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\__init__.py&quot;, line 240, in _check_versions
    module = importlib.import_module(modname)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File &quot;C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py&quot;, line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File &quot;C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\kiwisolver\__init__.py&quot;, line 8, in &lt;module&gt;
    from ._cext import (
ImportError: DLL load failed while importing _cext: The specified module could not be found.

I already tried reinstalling matplotlib and kiwisolver, but nothing helped. Even a google search didn't give me any results for this issue.

答案1

得分: 1

我遇到了同样的问题。

解决方案可以在这个问题中找到:

Matplotlib kiwisolver import problem _cext

解决方案只是运行:

pip install msvc-runtime
英文:

I had the same problem.

the solution is found on this question:

Matplotlib kiwisolver import problem _cext

The solution is just to run:

pip install msvc-runtime

huangapple
  • 本文由 发表于 2023年4月7日 04:24:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75953485.html
匿名

发表评论

匿名网友

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

确定