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

目录
相关文章
|
7月前
|
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命令后还需要删除文件夹中得几个文件夹,也就是...
69 1
成功解决ImportError: cannot import name ‘InvalidSchemeCombination‘ from ‘pip._internal.exceptions‘
成功解决ImportError: cannot import name ‘InvalidSchemeCombination‘ from ‘pip._internal.exceptions‘
ImportError: cannot import name ‘options‘ from ‘pyecharts‘
ImportError: cannot import name ‘options‘ from ‘pyecharts‘
485 0
ImportError: cannot import name ‘options‘ from ‘pyecharts‘
|
12月前
|
PyTorch 算法框架/工具 Python
代码import torch 报错 ImportError: numpy.core.multiarray failed to import
代码import torch 报错 ImportError: numpy.core.multiarray failed to import
245 0
|
12月前
|
Python
解决ImportError: cannot import name ‘NoReturn‘报错
解决ImportError: cannot import name ‘NoReturn‘报错
519 0
|
Python
rqalpha安装后使用报错:numpy.core.multiarray failed to import
rqalpha安装后使用报错:numpy.core.multiarray failed to import
66 0
【Bug记录】ImportError: cannot import name ‘fetch_mldata‘ from ‘sklearn.datasets‘
【Bug记录】ImportError: cannot import name ‘fetch_mldata‘ from ‘sklearn.datasets‘
442 0
|
计算机视觉 Python
python踩坑日记:ImportError: numpy.core.multiarray failed to import
写在前面 这个错误也是搞了好久都没有搞出来,参照网上的好多方法都不对 首先要知道这个错误是由于numpy版本与某个库文件包,比如opencv-python版本不匹配造成的😶‍🌫️
1952 0
ImportError: cannot import name ‘Page‘ from ‘pyecharts‘
ImportError: cannot import name ‘Page‘ from ‘pyecharts‘
407 0
ImportError: cannot import name ‘Page‘ from ‘pyecharts‘
|
计算机视觉 Python
ImportError: from . import _imaging as core
ImportError: from . import _imaging as core
230 0