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

Include requirements.txt file #1

Open
mearlboro opened this issue Dec 1, 2022 · 2 comments
Open

Include requirements.txt file #1

mearlboro opened this issue Dec 1, 2022 · 2 comments

Comments

@mearlboro
Copy link

mearlboro commented Dec 1, 2022

Dear team,

I appreciate you providing the course materials for users who do not want to rely on Google.
However, in lack of a requirements.txt file, reconstructing the necessary Python environment to run the notebooks is taking some time. Whilst you do specify some of the packages required the list is not complete. Moreover, some packages are being installed repeatedly inside code blocks in the Jupyter notebook, instead of being installed in the environment, i.e. the same pip install command is repeated many times in the same notebook. This is not recommended in lack of a virtual environment, but the instructions you provide do not stress the importance of using one, or offer alternatives to Anaconda. Providing a requirements.txt is the simplest and most agnostic way to support people in running this code locally inside a Python environment.
I have done this in preparation of attending the course, so below is the content of the requirements.txt file I used

graphviz
jupyterlab
jupyter_contrib_nbextensions
line_profiler
numba
pycallgraph2
pympler
@mearlboro
Copy link
Author

The error

'The pycallgraph module is not an IPython extension.'

has appeared after I managed to get the notebook to run, when trying to run the pycallgraph section in profile.ipynb.

This drove me to notice that:

  • pycallgraph has no longer been maintained in several years, and has been forked as pycallgraph2.
  • both Jupyter extensions and iPython were not listed in the above requirements.txt

I amended the issue to add iPython, pycallgraph2 and jupyter_contrib_nbextensions.

This also requires enabling Jupyter extensions, this is described for system-wide enabling here, or, if you're working in a python environment for example pipenv one can do

pipenv run jupyter contrib nbextension install --sys-prefix
pipenv run jupyter nbextension enable pycallgraph2 --sys-prefix 

and then after restarting the notebook server, go to the NBExtensions tab, untick "disable configuration for nbextensions without explicit compatibility", and make sure pycallgraph2 is ticked as well.

Running the relevant cell will then produce the call graph image as a PNG in the same directory you run notebooks.

@cmcooling
Copy link
Collaborator

Thanks again for finding these problems and suggesting the solutions. The method you suggest works, but it's quite a lot of work for students who are unfamiliar with the command line and Python package management. As a result, I've decided to remove the section on call graphs for now. It's not so bad as I don't think it's actually required for solving any of the problems in the course, and trying to find a good solution to this has caused me problems for a while. I may bring it back at some point - I'm considering trying GitHub Codespaces as a way to provide a pre-configured environment for students, and this would make it easier to use these packages.

In any case, your suggestion of a requirements file is still a good one, so I've added this for the other packages required for the course and updated "Packages" section of the readme. If you notice any problems with requirements file or the readme please feel free to let me know!

Thanks again for the feedback and suggestions.

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