computersciencer 2021-08-09 23:14 采纳率: 85.7%
浏览 294
已结题

请用力解决问题:python机器学习报错

我写的代码文件findKNNKValue.py的79行代码如下:
from sklearn import neighbors
运行程序后,报错信息如下:
Traceback (most recent call last):
File "E:\script\logisticsWeb\logisticsWeb\siteAnsys\findKNNKValue.py", line 79, in
from sklearn import neighbors
File "e:\anaconda3\lib\site-packages\sklearn_init_.py", line 82, in
from .base import clone
File "e:\anaconda3\lib\site-packages\sklearn\base.py", line 17, in
from .utils import IS_32BIT
File "e:\anaconda3\lib\site-packages\sklearn\utils_init
.py", line 23, in
from .class_weight import compute_class_weight, compute_sample_weight
File "e:\anaconda3\lib\site-packages\sklearn\utils\class_weight.py", line 7, in
from .validation import deprecate_positional_args
File "e:\anaconda3\lib\site-packages\sklearn\utils\validation.py", line 26, in
from .fixes import object_dtype_isnan, parse_version
File "e:\anaconda3\lib\site-packages\sklearn\utils\fixes.py", line 20, in
import scipy.stats
File "e:\anaconda3\lib\site-packages\scipy\stats_init
.py", line 391, in
from .stats import *
File "e:\anaconda3\lib\site-packages\scipy\stats\stats.py", line 174, in
from scipy.spatial.distance import cdist
File "e:\anaconda3\lib\site-packages\scipy\spatial_init
.py", line 102, in
from .geometric_slerp import geometric_slerp
File "e:\anaconda3\lib\site-packages\scipy\spatial_geometric_slerp.py", line 8, in
from scipy.spatial.distance import euclidean
File "e:\anaconda3\lib\site-packages\scipy\spatial\distance.py", line 122, in
from ..special import rel_entr
File "e:\anaconda3\lib\site-packages\scipy\special_init
.py", line 633, in
from . import _ufuncs
ImportError: cannot import name 'ufuncs' from partially initialized module 'scipy.special' (most likely due to a circular import) (e:\anaconda3\lib\site-packages\scipy\special_init.py)
请问怎么解决?

  • 写回答

1条回答 默认 最新

  • CSDN专家-HGJ 2021-08-09 23:38
    关注

    思路和建议:一是将第79行导入方式改成 from sklearn.neighbors import NearestNeighbors,代码其他原来用neighbors地方作相应修改。二是在anaconda中升级scipy

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 8月18日
  • 已采纳回答 8月10日
  • 创建了问题 8月9日

悬赏问题

  • ¥15 Workbench中材料库无法更新,如何解决?
  • ¥20 如何推断此服务器配置
  • ¥15 关于github的项目怎么在pycharm上面运行
  • ¥15 内存地址视频流转RTMP
  • ¥100 有偿,谁有移远的EC200S固件和最新的Qflsh工具。
  • ¥15 有没有整苹果智能分拣线上图像数据
  • ¥20 有没有人会这个东西的
  • ¥15 cfx考虑调整“enforce system memory limit”参数的设置
  • ¥30 航迹分离,航迹增强,误差分析
  • ¥15 Chrome Manifest扩展引用Ajax-hook库拦截请求失败