Skip to content

Instantly share code, notes, and snippets.

Star You must be signed in to star a gist
Save pandafulmanda/730a9355e088a9970b18275cb9eadef3 to your computer and use it in GitHub Desktop.
Setting up and using Python3 Virtualenv on Mac

Python3 Virtualenv Setup

Requirements
  • Python 3
  • Pip 3
$ brew install python3

Pip3 is installed with Python3

Installation

To install virtualenv via pip run:

$ pip3 install virtualenv
Usage

Creation of virtualenv:

$ virtualenv -p python3 <desired-path>

Activate the virtualenv:

$ source <desired-path>/bin/activate

Deactivate the virtualenv:

$ deactivate

About Virtualenv

@yeckfam
Copy link

yeckfam commented Jul 12, 2022

Got below error after enter: pip3 install virtualenv, how do I resolve this?

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: virtualenv in /Users/fanyang/Library/Python/3.8/lib/python/site-packages (20.15.1)
Requirement already satisfied: distlib<1,>=0.3.1 in /Users/fanyang/Library/Python/3.8/lib/python/site-packages (from virtualenv) (0.3.4)
Requirement already satisfied: six<2,>=1.9.0 in /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages (from virtualenv) (1.15.0)
Requirement already satisfied: platformdirs<3,>=2 in /Users/fanyang/Library/Python/3.8/lib/python/site-packages (from virtualenv) (2.5.2)
Requirement already satisfied: filelock<4,>=3.2 in /Users/fanyang/Library/Python/3.8/lib/python/site-packages (from virtualenv) (3.7.1)

@ziweiyang
Copy link

if it fails for you in: virtualenv -p python3 <desired_path> Try: python3 -m virtualenv <desired_path>

Thanks so much! Only this command gets worked for my Mac!

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