Skip to content

Instantly share code, notes, and snippets.

Forked from akszydelko/Python3 Virtualenv
Last active November 20, 2023 20:03
Star You must be signed in to star a gist
What would you like to do?
Setting up and using Python3 Virtualenv on Mac

Python3 Virtualenv Setup

  • Python 3
  • Pip 3
$ brew install python3

Pip3 is installed with Python3


To install virtualenv via pip run:

$ pip3 install virtualenv

Creation of virtualenv:

$ virtualenv -p python3 <desired-path>

Activate the virtualenv:

$ source <desired-path>/bin/activate

Deactivate the virtualenv:

$ deactivate

About Virtualenv

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!

Copy link

hello all,
I have the same error:

if it fails for you in:
virtualenv -p python3 <desired_path>
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 ???

Copy link

Creation of virtualenv:
python3 -m venv <desired_path>

To create a virtual environment, go to your project’s directory and run venv. If you are using Python 2, replace venv with virtualenv in the below commands.

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)

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