简体   繁体   English

导入 SMOTE 时出现不平衡学习模块 base.py 文件语法错误

[英]Imbalances-learn module base.py file syntax error coming up while importing SMOTE

I installed imbalanced-learn package using (Python 2.7):我使用(Python 2.7)安装了不平衡学习 package:

conda install -c conda-forge imbalanced-learn

after installing it, I tried to import SMOTE from the package.安装后,我尝试从 package 导入 SMOTE。

from imblearn.over_sampling import SMOTE

which gave the following error:这给出了以下错误:

File "C:\.conda\envs\py27\lib\site-packages\imblearn\base.py", line 21
    class SamplerMixin(BaseEstimator, metaclass=ABCMeta):
                                               ^
SyntaxError: invalid syntax

can anybody help me in resolving this error or point out if I didn't install the package correctly?谁能帮我解决这个错误或指出我是否没有正确安装 package?

The version that has been installed by conda is not compatible with Python 2 (I advise you to not use it since all datascience package stop to support it). conda安装的版本不兼容 Python 2 (我建议你不要使用它,因为所有数据科学 package 都停止支持它)。

You can see it because the syntax to the metaclass should be written in the following manner in Python 2:您可以看到它,因为元类的语法应该在 Python 2 中以以下方式编写:

class SamplerMixin(BaseEstimator):
    __metaclass__ = ABC

if I recall correctly如果我没记错的话

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使 base.py 存在,也没有名为“base”的模块 - No module named 'base' even though base.py exists Django入门-base.py-ImportError:没有名为Blog的模块 - Getting started with Django - base.py - ImportError: No module named blog 执行脚本时 pynput/keyboard/_base.py 下的 ValueError - ValueError under pynput/keyboard/_base.py while executing a script 导入 py 文件错误:没有名为“文件名”的模块 - importing py file error: no module named 'filename' mysqlclient 版本的错误仍然出现,如果从 base.py 检查删除后? - Error for version of mysqlclient still appears, after delete if check from base.py? SyntaxError:lib/python3.8/site-packages/sql_server/pyodbc/base.py django deploy on Linux 上的语法无效 - SyntaxError: invalid syntax on lib/python3.8/site-packages/sql_server/pyodbc/base.py django deploy on Linux 将.py文件作为模块导入时没有显示文档字符串? - Docstring not showing up when importing .py file as a module? Django:_rowfactory中的oracle / base.py中的“ int类型的参数不可迭代” - Django: “argument of type 'int' is not iterable” in oracle/base.py in _rowfactory Python 从另一个文件夹导入 .py 时找不到模块错误 - Python No module found error while importing .py from another folder 导入.py文件错误 - importing .py file error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM