“/opt/conda/lib/python3.10/site-packages/scipy/spatial/__init__.py "无法从”scipy.spatial“导入名称”QhullError"

jckbn6z7  于 2024-01-05  发布在  Python
关注(0)|答案(1)|浏览(337)

我正在使用Kaggle做一些工作。
由于某种原因,这一行:import imgaug as aug # data augmentation导致了这个错误:ImportError: cannot import name 'QhullError' from 'scipy.spatial' (/opt/conda/lib/python3.10/site-packages/scipy/spatial/__init__.py)
scipy1.11.1scikit-image0.21.0
我选择了>Always use the latest environment. Here is the code,它是一个从original tensorflow到pytorch的转换项目
我试过!pip install --upgrade --force-reinstall install scipy,但没有用。

  1. ---------------------------------------------------------------------------
  2. ImportError Traceback (most recent call last)
  3. Cell In[1], line 10
  4. 7 import h5py
  5. 8 import shutil
  6. ---> 10 import imgaug as aug # data augmentation
  7. 11 import numpy as np # linear algebra
  8. 12 import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
  9. File /opt/conda/lib/python3.10/site-packages/imgaug/__init__.py:9
  10. 4 # this contains some deprecated classes/functions pointing to the new
  11. 5 # classes/functions, hence always place the other imports below this so that
  12. 6 # the deprecated stuff gets overwritten as much as possible
  13. 7 from imgaug.imgaug import * # pylint: disable=redefined-builtin
  14. ----> 9 import imgaug.augmentables as augmentables
  15. 10 from imgaug.augmentables import *
  16. 11 import imgaug.augmenters as augmenters
  17. File /opt/conda/lib/python3.10/site-packages/imgaug/augmentables/__init__.py:8
  18. 6 from imgaug.augmentables.lines import *
  19. 7 from imgaug.augmentables.heatmaps import *
  20. ----> 8 from imgaug.augmentables.segmaps import *
  21. 9 from imgaug.augmentables.batches import *
  22. File /opt/conda/lib/python3.10/site-packages/imgaug/augmentables/segmaps.py:12
  23. 9 import six.moves as sm
  24. 11 from .. import imgaug as ia
  25. ---> 12 from ..augmenters import blend as blendlib
  26. 13 from .base import IAugmentable
  27. 16 @ia.deprecated(alt_func="SegmentationMapsOnImage",
  28. 17 comment="(Note the plural 'Maps' instead of old 'Map'.)")
  29. 18 def SegmentationMapOnImage(*args, **kwargs):
  30. File /opt/conda/lib/python3.10/site-packages/imgaug/augmenters/__init__.py:21
  31. 19 import imgaug.augmenters.pillike # use via: iaa.pillike.*
  32. 20 from imgaug.augmenters.pooling import *
  33. ---> 21 from imgaug.augmenters.segmentation import *
  34. 22 from imgaug.augmenters.size import *
  35. 23 from imgaug.augmenters.weather import *
  36. File /opt/conda/lib/python3.10/site-packages/imgaug/augmenters/segmentation.py:21
  37. 17 import numpy as np
  38. 18 # use skimage.segmentation instead `from skimage import segmentation` here,
  39. 19 # because otherwise unittest seems to mix up imgaug.augmenters.segmentation
  40. 20 # with skimage.segmentation for whatever reason
  41. ---> 21 import skimage.segmentation
  42. 22 import skimage.measure
  43. 23 import six
  44. File /opt/conda/lib/python3.10/site-packages/skimage/segmentation/__init__.py:7
  45. 5 from .slic_superpixels import slic
  46. 6 from ._quickshift import quickshift
  47. ----> 7 from .boundaries import find_boundaries, mark_boundaries
  48. 8 from ._clear_border import clear_border
  49. 9 from ._join import join_segmentations, relabel_sequential
  50. File /opt/conda/lib/python3.10/site-packages/skimage/segmentation/boundaries.py:5
  51. 2 from scipy import ndimage as ndi
  52. 4 from .._shared.utils import _supported_float_type
  53. ----> 5 from ..morphology import dilation, erosion, square
  54. 6 from ..util import img_as_float, view_as_windows
  55. 7 from ..color import gray2rgb
  56. File /opt/conda/lib/python3.10/site-packages/skimage/morphology/__init__.py:12
  57. 10 from ..measure._label import label
  58. 11 from ._skeletonize import medial_axis, skeletonize, skeletonize_3d, thin
  59. ---> 12 from .convex_hull import convex_hull_image, convex_hull_object
  60. 13 from .grayreconstruct import reconstruction
  61. 14 from .misc import remove_small_holes, remove_small_objects
  62. File /opt/conda/lib/python3.10/site-packages/skimage/morphology/convex_hull.py:4
  63. 2 from itertools import product
  64. 3 import numpy as np
  65. ----> 4 from scipy.spatial import ConvexHull, QhullError
  66. 5 from ..measure.pnpoly import grid_points_in_poly
  67. 6 from ._convex_hull import possible_hull

字符串

mklgxw1f

mklgxw1f1#

我也只是偶然遇到这个问题。我不知道它来自哪里,但我设法破解它,在从scipy导入任何东西之前运行以下代码片段:

  1. from scipy.spatial.qhull import QhullError
  2. from scipy import spatial
  3. spatial.QhullError = QhullError

字符串

相关问题