ImportError: cannot import name 'qmc' from 'scipy.stats' 解决办法

简介: ImportError: cannot import name 'qmc' from 'scipy.stats' 解决办法

1.现象


今天学习PaddleScience时,遇到qmc导入错误,具体如下:

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/__init__.py:107: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import MutableMapping
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/rcsetup.py:20: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import Iterable, Mapping
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/colors.py:53: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import Sized
Traceback (most recent call last):
  File "ldc2d_steady_train.py", line 15, in <module>
    import paddlescience as psci
  File "/home/aistudio/ldc_project/PaddleScience/paddlescience/__init__.py", line 21, in <module>
    from . import geometry
  File "/home/aistudio/ldc_project/PaddleScience/paddlescience/geometry/__init__.py", line 15, in <module>
    from .rectangular import Rectangular, Cube, CircleInRectangular, CylinderInCube
  File "/home/aistudio/ldc_project/PaddleScience/paddlescience/geometry/rectangular.py", line 19, in <module>
    from scipy.stats import qmc
ImportError: cannot import name 'qmc' from 'scipy.stats' (/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/scipy/stats/__init__.py)


经查发现


pip list|grep scipy
scipy                          1.6.3
Note: you may need to restart the kernel to use updated packages.

发现 aistudio 上默认scipy 版本为1.6.3,推测版本过低导致。


2.问题解决


qmc模块是在scipy的1.7.0版本(2021年7月左右)中添加的。 故需要更新软件包。

!pip install  -U scipy
pip list|grep scipy
scipy                          1.7.3
Note: you may need to restart the kernel to use updated packages.

更新后问题排除!!!

image.png

目录
相关文章
|
Python
python flask 后端报错 ImportError: cannot import name ‘cached_prope‘
问题python flask 后端报错 ImportError: cannot import name ‘cached_prope‘flask程序启动但抛出该错误,是因为werkzeug 版本过高,需要降低版本即可 解决:一般这种情况是需要注意第三方库版本的对应,werkzeug需要0.16.0 版本时 flask的版本应该时1.x.x 的版本,不能是2.x过高的版本。
195 0
成功解决ImportError: cannot import name ‘InvalidSchemeCombination‘ from ‘pip._internal.exceptions‘
成功解决ImportError: cannot import name ‘InvalidSchemeCombination‘ from ‘pip._internal.exceptions‘
|
TensorFlow 算法框架/工具 Python
python报错:ImportError: cannot import name ‘_tf_stack‘ from ‘tenso
ImportError: cannot import name ‘_tf_stack’ from ‘tensorflow.python’本来keras和tensorflow用得好好的,忽然今天报错导入包得时候直接报错。在网上找了很多方法,但是用处都不大,尝试了很多遍都不行。于是尝试将tensorflow和keras卸载重装。(需要彻底卸载,pip命令后还需要删除文件夹中得几个文件夹,也就是...
146 1
ImportError: cannot import name ‘options‘ from ‘pyecharts‘
ImportError: cannot import name ‘options‘ from ‘pyecharts‘
567 0
ImportError: cannot import name ‘options‘ from ‘pyecharts‘
|
6月前
|
Linux 开发者 iOS开发
ImportError: cannot import name ‘TypeAliasType‘ from ‘typing_extensions‘问题的解决
ImportError: cannot import name ‘TypeAliasType‘ from ‘typing_extensions‘问题的解决
343 0
|
机器学习/深度学习 PyTorch 算法框架/工具
|
Python
解决ImportError: cannot import name ‘NoReturn‘报错
解决ImportError: cannot import name ‘NoReturn‘报错
829 0
|
PyTorch 算法框架/工具 Python
代码import torch 报错 ImportError: numpy.core.multiarray failed to import
代码import torch 报错 ImportError: numpy.core.multiarray failed to import
530 0
ImportError: cannot import name ‘Page‘ from ‘pyecharts‘
ImportError: cannot import name ‘Page‘ from ‘pyecharts‘
493 0
ImportError: cannot import name ‘Page‘ from ‘pyecharts‘
【Bug记录】ImportError: cannot import name ‘fetch_mldata‘ from ‘sklearn.datasets‘
【Bug记录】ImportError: cannot import name ‘fetch_mldata‘ from ‘sklearn.datasets‘
516 0