在Jupyter Notebook运行ydata-profiling遇numba模块AttributeError求助
解决AttributeError: module 'numba' has no attribute 'generated_jit'问题
问题根源
numba从0.59版本开始移除了generated_jitAPI,而你当前使用的ydata-profiling==4.7.0依赖的visions库仍在调用这个已废弃的接口,导致报错。
解决方案
以下三种方法任选其一即可:
1. 降级numba到兼容版本
将numba版本锁定为0.58.x,该版本仍保留generated_jit,与ydata-profiling==4.7.0完全兼容。修改后的依赖列表如下:
numpy==1.24.3 pandas==1.4.1 scikit-learn==1.4.1.post1 pyyaml==6.0 dvc==3.48.4 mlflow==2.11.1 seaborn==0.11.2 matplotlib==3.5.1 boto3==1.18.60 jupyter==1.0.0 pandoc==2.3 ydata-profiling==4.7.0 numba==0.58.1
2. 升级ydata-profiling到适配新版本numba的版本
升级ydata-profiling到5.x及以上版本(如ydata-profiling==5.0.0),新版本已修复visions依赖对numba API的调用问题。注意升级时需确认其他依赖(如pandas)的版本兼容性。
3. 指定兼容的visions版本
直接添加visions==0.7.5到依赖列表,该版本已修复对numba废弃API的调用,无需修改numba版本:
numpy==1.24.3 pandas==1.4.1 scikit-learn==1.4.1.post1 pyyaml==6.0 dvc==3.48.4 mlflow==2.11.1 seaborn==0.11.2 matplotlib==3.5.1 boto3==1.18.60 jupyter==1.0.0 pandoc==2.3 ydata-profiling==4.7.0 numba==0.59.1 visions==0.7.5
验证步骤
修改依赖后重新构建Docker镜像,启动Jupyter Notebook,再次执行以下代码测试:
from ydata_profiling import ProfileReport profile = ProfileReport(merged_data) profile.to_notebook_iframe()
内容的提问来源于stack exchange,提问作者jupyter51
相关产品推荐
相关产品推荐

