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

Can't install d2l 1.0.3 on python 3.12.4 #2608

Open
TheJeffah opened this issue Jun 25, 2024 · 7 comments
Open

Can't install d2l 1.0.3 on python 3.12.4 #2608

TheJeffah opened this issue Jun 25, 2024 · 7 comments

Comments

@TheJeffah
Copy link

The D2L Package version 1.0.3 requires numpy 1.23.5. Python 3.12.4/pip 24.1 consider it(numpy 1.23.5) depreciated and does not conclude the installation. It's needed to update the D2L package to depend on numpy 2.0.0. I'm waiting for it.

Regards.

@slewsys
Copy link

slewsys commented Jul 18, 2024

The authors mention testing with Python 9. I haven't tried the ML code yet, but installation completes with the latest iteration of Python 11:

mkdir 'D2L Jupyter Notebooks'
cd !$
curl -sSLO https:/d2l-ai/d2l-en/releases/download/v1.0.3/d2l-en-1.0.3.zip
unzip ./d2l-en-1.0.3.zip
rm -rf __*
asdf install python 3.11
asdf local python 3.11
pip install -U pip wheel
pip install -U jupyterlab  numpy
pip install -U install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install -U d2l
cd pytorch/chapter_preliminaries
jupyter lab

Finally, double-click on index.ipynb in JupyterLab's file browser.

@TheJeffah
Copy link
Author

Hi @slewsys ! 🙂

I think It should be upgraded, doesn't it ? I can't go back to 3.9 or 3.11. Numpy is 2.0.0 and Python is 3.14. They are faster and many improvements. I don't use Jupyter. I use Spyder. Before upgrade Python, I was testing the code on 3.11 and it was working quite well. But, go back to 3.11... I can't. Sorry. 😇

@slewsys
Copy link

slewsys commented Jul 19, 2024

The following works for me using Python 3.12.4. I didn't adjust the version in d2l/__init__.py because only setup.py is modified:

git clone https:/d2l-ai/d2l-en.git
cd ./d2l-en
patch <<EOF
--- setup.py.orig	2024-07-19 06:38:57.169915071 +000
+++ setup.py		2024-07-19 06:40:25.545595707 +000
@@ -2,13 +2,13 @@
 import d2l
 
 requirements = [
-    'jupyter==1.0.0',
-    'numpy==1.23.5',
-    'matplotlib==3.7.2',
-    'matplotlib-inline==0.1.6',
-    'requests==2.31.0',
-    'pandas==2.0.3',
-    'scipy==1.10.1'
+    'jupyterlab==4.2.2',
+    'numpy==2.0.0',
+    'matplotlib==3.9.1',
+    'matplotlib-inline==0.1.7',
+    'requests==2.32.3',
+    'pandas==2.2.2',
+    'scipy==1.14.0'
 ]
 
 setup(
EOF
pip install -U pip wheel setuptools
python ./setup.py bdist_wheel
pip install -U ./dist/d2l-1.0.3-py3-none-any.whl

@TheJeffah
Copy link
Author

Man ! You nailed it !
Python skills !
Working beautifully here.
I was waiting for three weeks and now I can go back to test the codes.
Thanks @slewsys ! 🙂

But, could the requirements be like 'numpy>=1.23.5' ?
If so, it's just a matter of upgrade the setup.py on github. Isn't it ?

@TheJeffah
Copy link
Author

Bad news, @slewsys... 🙁

This is the message after executing the code:
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.
If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Ok. We tried. Let's go back to square one. D2l should be upgraded in its code to numpy 2.0.0, isn't it ?

@slewsys
Copy link

slewsys commented Jul 20, 2024

I'm not sure what module was compiled with NumPy 1.x? Python does a poor job of dependency resolution. So the burden is on the user to create a pristine environment for Python when installing packages with lots of dependencies. The most common way of doing that is with a so-called virtual environment:

python -m venv d2l-venv
source d2l-venv/bin/activate
# Inside the Python virtual environment d2l-venv, run:
pip install -U pip wheel
pip install -U dist/d2l-1.0.3-py3-none-any.whl

You'll want to reinstall Spyder and so on in this virtual environment as well. To leave the virtual environment, run:

deactivate

To return to the virtual environment at some later point, cd to the d2l-en repository and run:

source d2l-venv/bin/activate

If you still encounter issues, try to provide the steps needed to reproduce the problem. Hope that helps!

@TheJeffah
Copy link
Author

Almost there. The virtual environment worked quite well. Everything installed. But now the problem is spyder. It's getting segmentation fault when launching. I see python 3.12 as interpreter in the virtual environment. I think it won't work. We are trying to make a solution for something downgraded.
It's just a matter of upgrade the project to numpy 2 and that's it !

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