Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when installing d2l: module pkgutil has no attribute ImpImporter. #2625

Open
hamiddashti opened this issue Nov 19, 2024 · 2 comments
Open

Comments

@hamiddashti
Copy link

hamiddashti commented Nov 19, 2024

I am trying to install the d2l library using the pip install d2l==1.0.3 and I get the following error:

AttributeError: module pkgutil has no attribute ImpImporter. Did you mean: zipimporter note: This error originates from a subprocess, and is likely not a problem with pip.

How can I solve this? I have my conda env setup properly.

Thanks!

@cmacfarl
Copy link

cmacfarl commented Dec 7, 2024

I am running into this problem also. It is a conflict between python 3.12 and numpy 1.23.5.

d2l has a hard requirement on numpy 1.23.5

Collecting numpy==1.23.5 (from d2l==1.0.3)
  Using cached numpy-1.23.5.tar.gz (10.7 MB)

numpry 1.23.5 uses ImpImporter. Python 3.12 removed support for pkgutil.ImpImporter.

I've confirmed that numpy 1.26.4 has fixed this problem, but that doesn't fix d2l's requirement for 1.23.5.

@cmacfarl
Copy link

cmacfarl commented Dec 7, 2024

This patch...

diff --git a/setup.py b/setup.py
index 2eb8e297..d7923e01 100644
--- a/setup.py
+++ b/setup.py
@@ -3,12 +3,12 @@ import d2l

 requirements = [
     'jupyter==1.0.0',
-    'numpy==1.23.5',
+    'numpy==1.26.4',
     'matplotlib==3.7.2',
     'matplotlib-inline==0.1.6',
     'requests==2.31.0',
     'pandas==2.0.3',
-    'scipy==1.10.1'
+    'scipy==1.14.0'
 ]

 setup(

Along with...

pip install -U pip wheel setuptools
python ./setup.py bdist_wheel
pip install -U ./dist/d2l-1.0.3-py3-none-any.whl

Results in a successful install using python 3.12. You may or may not have to install gfortran and libopenblas-dev depending upon your distro to get scipi to build. Numpy 1.26 required the uprev scipi.

Not tested yet to see if this doesn't break somehow in runtime.

Hat tip to @slewsys and #2608 (comment) for the pointer on how to rebuild the wheel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants