当前位置:   article > 正文

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

pyhton 3.12.1 安装 d2l

报错分析

在这里插入图片描述上述的截图中,安装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'
    ]
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
  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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/224961
推荐阅读
相关标签
  

闽ICP备14008679号