2025年2月15日 星期六

Python Tutorial: VENV (Windows) - Summary

 

Python Tutorial: VENV (Windows) - Summary

  1. Introduction to Virtual Environments (00:00 - 00:27)

    • Overview of the built-in venv module in Python.
    • Comparison with virtualenv and pipenv.
    • Focus on Windows usage in this tutorial.
  2. Why Use Virtual Environments? (00:27 - 01:25)

    • Avoid dependency conflicts between different projects.
    • Example: Running Django 1 and Django 2 separately without conflicts.
    • Ensures project-specific package management.
  3. Creating a Virtual Environment (01:25 - 03:15)

    • Requires Python 3.3 or higher.
    • Command: python -m venv <environment_name>.
    • Example: Creating project_env on the desktop.
  4. Activating and Using the Virtual Environment (03:15 - 05:04)

    • Activation command: Scripts\activate.bat (Windows).
    • Verification using where python.
    • Installed packages can be checked with pip list.
  5. Installing Packages and Managing Dependencies (05:04 - 07:04)

    • Install packages using pip install <package_name>.
    • Use pip freeze > requirements.txt to export dependencies.
    • Allows recreating environments using pip install -r requirements.txt.
  6. Deactivating and Deleting the Virtual Environment (07:04 - 08:08)

    • Deactivation: deactivate.
    • Deletion: rmdir /s /q <environment_name> or manually remove the folder.
  7. Best Practices (08:08 - 11:43)

    • Place virtual environments inside project folders.
    • Avoid committing virtual environments to version control (use .gitignore).
    • Store dependencies in requirements.txt.
  8. Creating a Virtual Environment with System Packages (12:47 - 15:57)

    • Use --system-site-packages to access global Python packages.
    • Installed packages within the environment do not affect system packages.
    • pip list --local shows only locally installed packages.
  9. Final Thoughts and Recommendations (15:57 - End)

    • venv is simpler than virtualenv or pipenv, and suitable for most cases.
    • Encouragement to ask questions and support the channel.

This summary captures the key points of the tutorial while maintaining a structured flow. Let me know if you need any refinements! 😊

沒有留言:

張貼留言

精選文章

手機使用VPN進入NAS、DaikinAPP時,仍能使用其他APP如銀行,連上WIFI 或行動網路

為了避免手機使用VPN進入NAS、DaikinAPP時,仍能使用其他APP如銀行,連上WIFI 或行動網路,要修改Router Policy設定?需要把家中屬於VPN的網段設備與其他區隔?要如何設定? 為了達成您的需求: ✅ 手機連上 VPN(例如連回家中 TP-Link ER...