我无法在Python3虚拟环境中导入jupyter notebook中的category_encoders模块。
错误
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-15-86725efc8d1e> in <module>()
9 from plotly import graph_objs
10 from datetime import datetime
---> 11 import category_encoders as ce
12
13 import sklearn
ModuleNotFoundError: No module named 'category_encoders'
"which pip“的输出
/opt/virtual_env/py3/bin/pip
"pip show category_encoders“的输出是
Name: category-encoders
Version: 1.3.0
Summary: A collection sklearn transformers to encode categorical variables as numeric
Home-page: https://github.com/wdm0006/categorical_encoding
Author: Will McGinnis
Author-email: will@pedalwrencher.com
License: BSD
Location: /opt/virtual_env/py3/lib/python3.6/site-packages
Requires: numpy, pandas, statsmodels, scikit-learn, patsy, scipy
Required-by:
"pip list“的输出
Package Version
------------------- -------
absl-py 0.7.0
astor 0.7.1
backcall 0.1.0
category-encoders 1.3.0
cycler 0.10.0
发布于 2019-04-08 15:06:55
pip install --upgrade category_encoders
现在,重新启动内核
import category_encoders as...
等等
此外,您还可以查看sk-learn的预处理类CategoricalEncoder...
from sklearn.preprocessing import CategoricalEncoder
从这里获取sk-learn,
pip install git+git://github.com/scikit-learn/scikit-learn.git
或者简单地说
pip install sklearn
发布于 2021-06-16 17:47:39
我使用的是蟒蛇环境。
最初,我使用pip (在conda环境中)安装了category_encoders
,但它无法解析。然后我从pip卸载了category_encoders`。
pip uninstall category-encoders
并使用conda进行安装:
conda install -c conda-forge category_encoders
这就解决了问题。
发布于 2020-08-13 05:00:17
如果您已经为您的虚拟环境(本例中为‘py3’)提供了访问系统站点包目录的权限,那么您可以尝试将包安装到您的基本(根)环境中。
在您的系统中搜索'pyvenv.cfg‘文件,并检查它是否包含:
include-system-site-packages = true
如果是,请按照here的说明将软件包安装到根环境中,并尝试将其再次导入到Jupyter Notebook中。
https://stackoverflow.com/questions/54265717
复制相似问题