【问题标题】:While importing train_test_split from from sklearn.model_selection, why am I getting the error "AttributeError: module 'attr' has no attribute 's'"?从 sklearn.model_selection 导入 train_test_split 时,为什么会出现错误“AttributeError:模块 'attr' 没有属性 's'”?
【发布时间】:2020-02-16 16:50:41
【问题描述】:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt 
import seaborn as sns
import sklearn
from sklearn.model_selection import train_test_split
import statsmodels.api as sm

在 Jupyter Notebook 中运行此单元时,出现以下错误:

C:\Anaconda\lib\site-packages\_pytest\_code\__init__.py in <module>
      1 """ python inspection/code generation API """
----> 2 from .code import Code  # noqa
      3 from .code import ExceptionInfo  # noqa
      4 from .code import filter_traceback  # noqa
      5 from .code import Frame  # noqa

C:\Anaconda\lib\site-packages\_pytest\_code\code.py in <module>
    390 
    391 
--> 392 @attr.s(repr=False)
    393 class ExceptionInfo(Generic[_E]):
    394     """ wraps sys.exc_info() objects and offers

AttributeError: module 'attr' has no attribute 's'

有人可以解释发生了什么吗?

【问题讨论】:

    标签: python machine-learning scikit-learn jupyter-notebook


    【解决方案1】:

    这将解决您的问题 在终端或笔记本中键入这些命令

    pip 卸载属性 点安装属性

    【讨论】:

    • 我的 setup.py 文件中列出了 attr,它导致 pytest 抛出 attr does not have attribute s 错误——这修复了它!谢谢~
    猜你喜欢
    • 2018-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-01
    • 2022-12-07
    • 2017-04-05
    相关资源
    最近更新 更多