Skip to content

Use !uv pip install in Jupyter notebooks#75

Merged
glenn-jocher merged 18 commits intomainfrom
uv
Aug 25, 2025
Merged

Use !uv pip install in Jupyter notebooks#75
glenn-jocher merged 18 commits intomainfrom
uv

Conversation

@RizwanMunawar
Copy link
Contributor

@RizwanMunawar RizwanMunawar commented Aug 25, 2025

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Switched all notebook installation commands to use uv for faster, more reliable package installs 🚀

📊 Key Changes

  • Replaced pip install and %pip install with !uv pip install across multiple notebooks (e.g., object counting, heatmaps, tracking, various training guides, Florence-2, Google Gemini, OpenAI integration, SAHI, SAM/SAM2).
  • Updated combined installs accordingly, e.g.:
    • !uv pip install ultralytics
    • !uv pip install transformers==4.49.0 ultralytics
    • !uv pip install -U -q google-genai ultralytics
    • !uv pip install ultralytics sahi

🎯 Purpose & Impact

  • Faster, more deterministic installs ⚡: uv speeds up dependency resolution and leverages caching, improving setup times in notebooks and CI.
  • Improved reliability ✅: Reduces common pip resolver issues and version conflicts, leading to smoother first-time runs.
  • Minimal behavior change 🧠: Notebook logic and outputs remain the same; only the install mechanism changes.
  • Note for users 🧩: uv must be available in the environment. If missing, install it first:
    pip install uv
    uv pip install ultralytics
  • Broad compatibility 🌍: Benefits users across Colab, local, and cloud setups by making environment setup more robust.

See the Ultralytics Docs for details: https://docs.ultralytics.com

Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
@UltralyticsAssistant UltralyticsAssistant added dependencies Dependencies and packages documentation Improvements or additions to documentation labels Aug 25, 2025
@UltralyticsAssistant
Copy link
Member

👋 Hello @RizwanMunawar, thank you for submitting an ultralytics/notebooks 🚀 PR! This is an automated response to help speed things up—an Ultralytics engineer will review and assist you shortly.

To ensure a seamless integration of your work, please review the following checklist:

  • Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
  • Synchronize with Source: Confirm your PR is synchronized with the ultralytics/notebooks main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
  • Update Documentation: Update the relevant documentation for any new or modified features.
  • Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
  • Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
  • Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

Additional notes for this PR (notebook install command updates) 📓:

  • Please confirm all modified notebooks execute end-to-end in common environments (Colab and local Jupyter) with the new !uv pip install ... cells.
  • Since uv may not be present everywhere, consider a lightweight fallback for robustness. For example:
    try:
        import uv
        !uv pip install ultralytics
    except Exception:
        !pip install ultralytics
  • Ensure consistent use of ! shell invocations in notebooks (avoid mixing %pip and !uv pip in the same notebook).
  • If any README or notebook text mentions pip install, update the text cell(s) to reflect uv usage where appropriate for consistency.
  • Double-check that package pins and multi-package installs (e.g., transformers==4.49.0 ultralytics, ultralytics sahi) behave as expected with uv.

For more guidance, please refer to our Contributing Guide. Don’t hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! ⚡️🚀

Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Signed-off-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
@RizwanMunawar
Copy link
Contributor Author

@glenn-jocher Ok, I opened this PR to use uv for the installation of dependencies. Thank you.

@RizwanMunawar RizwanMunawar self-assigned this Aug 25, 2025
@glenn-jocher
Copy link
Member

@RizwanMunawar looks good!

@glenn-jocher glenn-jocher merged commit 2c9e3f2 into main Aug 25, 2025
2 checks passed
@glenn-jocher glenn-jocher deleted the uv branch August 25, 2025 12:37
@UltralyticsAssistant
Copy link
Member

Merged! 🚀 Huge thanks to @RizwanMunawar for leading this and to @glenn-jocher for the support. As Grace Hopper said, “The most dangerous phrase in the language is, ‘We’ve always done it this way.’” Switching notebooks to uv elevates reliability and speed across Colab, local, and cloud runs—making first-time experiences smoother for everyone.

If uv isn’t available:

pip install uv
uv pip install ultralytics

See the Ultralytics Docs for details: https://docs.ultralytics.com

Appreciate the thoughtful upgrade and the attention to developer experience—awesome work! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Dependencies and packages documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants