Installing PyTorch on macOS Using Virtual Environment (venv)


Creating virtual environment

term@mac AI_Codes $ python3 -m venv path/to/venv

Activate the virtual environment

term@mac AI_Codes $ source .venv/bin/activate (.venv) term@mac AI_Codes $

Installing pytorch

(.venv) term@mac AI_Codes $ pip3 install torch torchvision
All systems normal

© 2025 2023 Sanjeeb KC. All rights reserved.