Summary of "You MUST WATCH THIS before installing PYTHON. PLEASE DON'T MAKE this MISTAKE."
Summary of “You MUST WATCH THIS before installing PYTHON. PLEASE DON’T MAKE this MISTAKE.”
This video provides a crucial guide for beginners on how to properly install Python and manage project dependencies using virtual environments. The presenter emphasizes common pitfalls beginners face when installing Python traditionally and explains why virtual environments are essential for avoiding conflicts between projects.
Main Ideas and Lessons
-
Common Beginner Mistake: Installing Python system-wide and installing packages globally leads to dependency conflicts when working on multiple projects with different requirements.
-
Problem with Global Installation:
- Installing packages globally can clutter your system with unnecessary packages.
- Different projects may require different versions of the same package, causing one project to break when you update or change dependencies for another.
- Installing multiple Python versions and managing PATH variables manually often leads to confusion and broken projects.
-
What are Virtual Environments?
- Virtual environments are isolated “sandboxes” for each Python project.
- Each environment has its own Python interpreter and packages, preventing conflicts between projects.
- They allow you to maintain different dependencies and Python versions for different projects without interference.
-
Benefits of Virtual Environments:
- Avoid package version conflicts.
- Facilitate collaboration by ensuring everyone uses the same environment setup.
- Keep your system clean and organized.
Step-by-Step Methodology for Installing Python and Setting Up a Virtual Environment (Windows)
-
Download Python:
- Go to python.org → Downloads.
- Download the latest stable version (e.g., Python 3.8.3 at the time of the video).
-
Prepare Directories:
- Open Command Prompt.
- Create a directory for Python installation (e.g.,
mkdir PIVERT). - Create a directory for Python projects (e.g.,
mkdir PIPROJ).
-
Install Python (Custom Installation):
- Run the Python installer.
- Choose Customize installation.
- Do NOT tick “Add Python to PATH” during this installation to avoid conflicts with existing Python versions.
- Set the installation directory to the folder created earlier (e.g.,
PIVERT\Python3.8.3). - Complete the installation.
-
Create a Virtual Environment:
- Navigate to your project directory (
cd PIPROJ). - Run the command to create a virtual environment:
bash <path-to-python-executable> -m venv myenvExample:bash C:\Users\Giles\PIVERT\Python3.8.3\python.exe -m venv myenv - This creates a folder
myenvcontaining an isolated Python environment.
- Navigate to your project directory (
-
Activate the Virtual Environment:
- On Windows, run:
bash myenv\Scripts\activate - You will see the environment name (
myenv) appear in the command prompt, indicating the environment is active.
- On Windows, run:
-
Use Python and Install Packages:
- Run Python inside the environment:
bash python - Test by printing or running commands like:
python print("hello world") - Install packages using pip:
bash pip install numpy - Packages installed here are isolated to this environment only.
- Run Python inside the environment:
-
Deactivate the Virtual Environment:
- When done, exit the environment by running:
bash deactivate
- When done, exit the environment by running:
Additional Notes
- The presenter briefly mentions that the commands differ slightly for Mac/Linux users.
- The video also includes a brief, unrelated guitar lesson and a personal note about the presenter being a physicist, showing Maxwell’s equations in the background as a fun fact.
Speakers/Sources Featured
- Main Speaker: The video presenter (name not given, but refers to himself as “Giles” based on folder paths).
- No other speakers or external sources are featured in the video.
This guide is essential for anyone new to Python to avoid common installation and environment management mistakes and to ensure smooth project development workflows.
Category
Educational