Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pandafulmanda/730a9355e088a9970b18275cb9eadef3 to your computer and use it in GitHub Desktop.
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

@evanrianto
Copy link

Hi, what if my macOS already has python3 and if I installed python3 via brew, its not going to use the brew version. What should I do ? Thanks!

@NuraiymS
Copy link

hello all,
I have the same error:

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

If i use both of this i get this error
Someone help me rectify it
zsh: parse error near `\n'

can someone help me please ???

@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