neonwatty / machine_learning_refined

Notes, examples, and Python demos for the 2nd edition of the textbook "Machine Learning Refined" (published by Cambridge University Press).
Other
1.7k stars 610 forks source link

conda build failed with matplotlib pinned to v3.1.0 (why OLD version)? Will attempt to float all dependencies to latest... #25

Closed richlysakowski closed 2 years ago

richlysakowski commented 2 years ago

the conda build method did not work using the requirements.txt file

conda create python=3.8 --name mlr2 --file requirements.txt

The latest version of matplotlib is 3.5.2.
v3.1.0 is obsolete has a dependency on some outdated package.

Is there some reason that matplotlib is pinned to 3.1.0 and all the other package dependencies are allowed to float to the latest versions?

Below is my conda output. Initially I tried it using the command on the githut package, but conda failed with a lot of incompatiblity conflicts.

Then I tried conda install for all packages EXCEPT the pinned matplotlib=3.1.0 and everything worked. Next, I tried to install matplotlib=3.1.0 and got the output below.

(mlr2) C:\Users\richadmin\Desktop\00_PythonWIP_2022\02-Borhani-ML-Refined-2021>conda install matplotlib==3.1.0
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.  
Solving environment: - Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  - matplotlib==3.1.0 -> python[version='>=3.6,<3.7.0a0|>=3.7,<3.8.0a0']

Your python: python=3.8

If python is on the left-most side of the chain, that's the version you've asked for.  When python appears to the right, that indicates that the thing on the left is somehow not available for the python version you are constrained to. Note that conda will not change your python version to a different minor version unless you explicitly specify that.

I just installed into the conda environment with everything the latest version (Python 3.8 and all other packages in the requirements.txt file) and then matplotlib (floating to the LATEST VERSION) and it worked. I will try running the code examples and see if there are any bugs or errors due to the later version of matplotlib.

I will report back after I have gone through many of the notebooks.

neonwatty commented 2 years ago

Thanks for reporting this issue!

matplotlib alone has been pinned to an earlier version (3.1.0) because this version was used during development of the animation engine for the notes/notebooks. Newer versions of matplotlib seem to break the animations for some users, and we do not at present have resources to upgrade the engine.

However your suggestion to pin other modules (to prevent conflicts with this older version of matplotlib) is duly noted - I will investigate additional pins and update our requirements.

In terms of your conda install - from the above error it looks like using python 3.6 would at least solve this particular error. So you can try building the conda env as

conda create python=3.6 --name mlr2 --file requirements.txt

I've successfully tested this on an Ubuntu 20.04 server and OSX 12.4 Monterey - but let me know what happens on your end.

If insurmountable errors continue I would strongly suggest using the docker install.

richlysakowski commented 2 years ago

Using Python 3.6 and updated matplotlib worked. I got it working using "%matplotlib notebook" but it is finicky using JupyterLab. It does not work with either %matplotlib widget" or %matplotlib inline" I dropped back to Jupyter Classic Notebook and it worked much better.
I am using Windows 10.

My main goal is to use JupyterLab with JupyterLab iPyWidgets for interactive data controls such as you show in the animiated GIFs. After running through the notebooks, I realized that you are rendering the data analytics results as a series of images, then making an "animation" video in mp4 format, which is then played in Jupyter. Overall it works better in Jupyter Classic Notebook.

neonwatty commented 2 years ago

👍 - I've updated the conda install instructions to reflect the learnings here - please let me know if any additional issues arise!