-->

DEVOPSZONES

  • Recent blogs

    how to create and activate a python virtual enviornment

     

    To activate a Python virtual environment on macOS, follow these steps depending on how you created it:


    🛠️ Step-by-Step

    1. Create a virtual environment (if not already done):

    bash
    python3 -m venv myenv

    This creates a folder myenv with the virtual environment.


    2. Activate the virtual environment:

    bash
    source myenv/bin/activate

    You'll know it's activated when your shell prompt shows the environment name like:

    bash
    (myenv) your-mac:project-folder user$

    🧪 To test:

    bash
    which python

    It should point to something like:

    swift
    /path/to/myenv/bin/python

    ❌ To deactivate:

    bash
    deactivate

    No comments