简体   繁体   English

Jupyter:安装后没有名为“imblearn”的模块

[英]Jupyter: No module named 'imblearn" after installation

I installed "imbalanced-learn" (version 0.3.1) on ANACONDA Navigator.我在 ANACONDA Navigator 上安装了“不平衡学习”(版本 0.3.1)。 When I ran an example from the imbalanced-learn website using Jupyter (Python 3):当我使用 Jupyter (Python 3) 从不平衡学习网站运行一个示例时:

from imblearn.datasets import make_imbalance
from imblearn.under_sampling import NearMiss
from imblearn.pipeline import make_pipeline
from imblearn.metrics import classification_report_imbalanced

I got an message regarding "ModuleNotFoundError".我收到有关“ModuleNotFoundError”的消息。

ModuleNotFoundError: No module named 'imblearn' ModuleNotFoundError:没有名为“imblearn”的模块

How could I resolve this?我该如何解决这个问题?

Problems importing imblearn python package on ipython notebook 在 ipython notebook 上导入 imblearn python 包的问题

Found the answer here.在这里找到了答案。 This worked for me这对我有用

conda install -c glemaitre imbalanced-learn

This worked for me:这对我有用:

!pip install imblearn

Then, I was able to import SMOTE package.然后,我能够导入SMOTE包。

from imblearn.over_sampling import SMOTE

I have faced the same problem and I installed imblearn first by typing this command:我遇到了同样的问题,我首先通过输入以下命令安装了imblearn

!pip install imblearn  

in jupyter notebook and then it is fine在 jupyter notebook 中,然后就可以了

Just in case someone encounters this problem on Google Cloud Jupyter notebook instances, using pip3 to install imblearn made it work for me, after failing with pip command:万一有人在 Google Cloud Jupyter 笔记本实例上遇到此问题,使用pip3安装 imblearn 使其对我有用,在使用pip命令失败后:

pip3 install imblearn

or directly in the notebook:或直接在笔记本中:

!pip3 install imblearn

You should see imblearn (0.0) and imbalanced-learn (4.3) in your pip list.您应该在 pip 列表中看到imblearn (0.0)不平衡学习 (4.3)

NB!注意! Make sure to reload your notebooks (File -> Close and Shutdown), otherwise it might fail to import the library after install.确保重新加载您的笔记本(文件 -> 关闭并关闭),否则安装后可能无法导入库。

conda install -c conda-forge imbalanced-learn 

它只是担心问题

imbalanced-learn is currently available on the PyPi's reporitories and you can install it via pip:不平衡学习目前在 PyPi 的报告中可用,您可以通过 pip 安装它:

pip install -U imbalanced-learn

The package is release also in Anaconda Cloud platform:该软件包也在 Anaconda Cloud 平台中发布:

conda install -c conda-forge imbalanced-learn

One of the below four commands should work.以下四个命令之一应该可以工作。 Only the 3rd worked for me.只有第三个对我有用。

conda install -c conda-forge imbalanced-learn conda install -c conda-forge 不平衡学习

conda install -c conda-forge/label/gcc7 imbalanced-learn conda install -c conda-forge/label/gcc7 不平衡学习

conda install -c conda-forge/label/cf201901 imbalanced-learn conda install -c conda-forge/label/cf201901 不平衡学习

conda install -c conda-forge/label/cf202003 imbalanced-learn conda install -c conda-forge/label/cf202003 不平衡学习

Just check if you antivirus or firewall is blocking the download process.只需检查您的防病毒软件或防火墙是否阻止了下载过程。 I too had the same issue.我也有同样的问题。 This happens when you try to install through Anaconda.当您尝试通过 Anaconda 安装时会发生这种情况。 During the installation process there occurs a permission error.在安装过程中出现权限错误。 This is probably due to antivirus blocking the download process.这可能是由于防病毒软件阻止了下载过程。

打开 Anaconda Prompt 并输入

pip install imbalanced-learn --user

我正在使用 Jupyter 笔记本,这对我有用:

pip install imblearn

我在我的 Jupyter Notebook 中使用了这段代码,它运行良好。

! pip install imbalanced-learn

Use this:用这个:

!pip3 install imblearn --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --user

This will override SSL certificate requirement and complete the installation.这将覆盖 SSL 证书要求并完成安装。

If after this you still get the error, restart the kernel and run just the import code, not this install command again.如果在此之后您仍然收到错误,请重新启动内核并仅运行导入代码,而不是再次运行此安装命令。 That will import imblearn successfully.这将成功导入 imblearn。

The below code is the most updated one:以下代码是最新的代码:

conda update -n base -c defaults conda conda update -n base -c 默认 conda

from imblearn.over_sampling import SMOTE从 imblearn.over_sampling 导入 SMOTE

I needed to upgrade pip first:我需要先升级 pip:

pip3 install --upgrade pip

then, and only then, was I able to install imbalanced-learn:然后,只有那时,我才能安装不平衡学习:

pip3 install imbalanced-learn

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

相关问题 ModuleNotFoundError:没有名为“imblearn”的模块 - ModuleNotFoundError: No module named 'imblearn' 成功安装后,“没有名为wordcloud的模块” - “No module named wordcloud” after successful installation 安装后没有名为“atari_py”的模块 - No module named 'atari_py' after installation 获取ImportError:安装后没有名为“ Crypto”的模块 - Getting ImportError: No module named 'Crypto' after installation ModuleNotFoundError: 在安装 cython 后安装 pycocotools 期间没有名为“Cython”的模块 - ModuleNotFoundError: No module named 'Cython' during pycocotools install after cython installation Jupyter Notebook:没有名为 pandas 的模块 - Jupyter Notebook: no module named pandas ModuleNotFoundError:jupyter 中没有名为“pymysql”的模块 - ModuleNotFoundError: No module named 'pymysql' in jupyter 安装graphviz,没有名为graphviz的模块 - installation graphviz, no module named graphviz 运行 pip3 install pandas_datareader 后,Jupyter (Anaconda) 中没有名为“pandas_datareader”的模块 - No module named 'pandas_datareader' in Jupyter (Anaconda) after I run pip3 install pandas_datareader 为什么imblearn可与jupyter笔记本python 2一起使用但不能与3一起使用? - Why does imblearn works with jupyter notebook python 2 but not 3?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM