Jupyter-ai generate function produces error

Oops. Sorry, I missed the source of that ‘Tip’.

For the edification of others:
LLM gpt-oss is giving out outdated advice there, where it says “include installation instructions at the top (e.g., !pip install pandas matplotlib).”

The use of %pip install pandas matplotlib is current best practice. The magic variation was introduced in 2019 to overcome shortcomings possible with what that LLM was recommending.
It is universal as it works in JupyterLite where what the LLM suggested does not. Even Google Colab now supports the magic version.
Those interested can see more about the modern %pip install command here. For more background, the second paragraph here goes into more details about why the exclamation point may lead to issues.


This is of course a Sisyphean struggle as outdated things get entrenched by AI trained on things from the past where the old advice outnumbers the current.

1 Like