Python3.12安装d2l库提示module ‘pkgutil‘ has no attribute ‘ImpImporter‘

报错分析

在这里插入图片描述上述的截图中,安装d2l时,指定了numpy的版本且从源码构建,报错提示ImpImporter找不到(此属性在Python 3.12中被移除,这儿也提到了一些解决办法,但在Mac OS上不生效),猜测直接升级numpy版本也能解决此问题。

解决办法

  1. PyPI下载d2l源码
  2. 解压缩源码,更改setup.py文件里的requirements
    # 以2024-02-07时最新版本为准
    requirements = [
        'jupyter==1.0.0',
        'numpy==1.26.3',
        'matplotlib==3.8.2',
        'matplotlib-inline==0.1.6',
        'requests==2.31.0',
        'pandas==2.2.0',
        'scipy==1.12.0'
    ]
    
  3. 安装修改后的源码:python3 setup.py install
    Help on package d2l:
    
    NAME
        d2l - Saved source code for "Dive into Deep Learning" (https://d2l.ai).
    
    DESCRIPTION
        Please import d2l by one of the following ways:
    
        from d2l import mxnet as d2l  # Use MXNet as the backend
        from d2l import torch as d2l  # Use PyTorch as the backend
        from d2l import tensorflow as d2l  # Use TensorFlow as the backend
        from d2l import jax as d2l  # Use Jax as the backend
    
    PACKAGE CONTENTS
        jax
        mxnet
        tensorflow
        torch
    
    DATA
        __annotations__ = {}
    
    VERSION
        1.0.3
    
    FILE
        /Users/bytedance/Downloads/d2l-1.0.3/d2l/__init__.py
    
  • 13
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值