Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to run virtualenv python on mac

I am trying to use virtualenv to create a virtual python environment on my mac. I have downloaded virtualenv however I can't run it because it can't find the path to my installation of python3 even though I am supplying the correct path. Here is the command I have run and the response:

virtualenv --python=/usr/local/bin/python3 newfolder
zsh: /usr/local/bin/virtualenv: bad interpreter: /usr/local/opt/python3/bin/python3.6: no such file or directory

Also I have tried running the command with quotes like so:

virtualenv --python='/usr/local/bin/python3' newfolder
zsh: /usr/local/bin/virtualenv: bad interpreter: /usr/local/opt/python3/bin/python3.6: no such file or directory

Please note I am supplying the correct path to python3 as far as I can tell.
Here is what I get when I run which python3

which python3
/usr/local/bin/python3

Also virtualenv appears to be correctly installed. Here is evidence for this:

pip3 install virtualenv
Requirement already satisfied: virtualenv in /Users/mathewlewis/Library/Python/3.7/lib/python/site-packages (16.7.9)

Also, in case this is relevant, the software I have is currently mac os catalina 10.15.2

Not only would I like a solution (as has been given at this point) I would also like a reason why this didn't work.

like image 348
Mathew Avatar asked Jan 08 '20 00:01

Mathew


People also ask

How do I start virtualenv in Python?

Virtual environments in Python 2To install virtualenv, just use pip install virtualenv . To create a virtual environment directory with it, type virtualenv /path/to/directory . Activating and deactivating the virtual environment works the same way as it does for virtual environments in Python 3 (see above).

Where is virtualenv installed on Mac?

It will get installed in the venv/ folder, and not conflict with other projects.


2 Answers

Try:

python3 -m venv venv
source ./venv/bin/activate
like image 169
aminrd Avatar answered Nov 04 '22 08:11

aminrd


Your virtualenv script uses bad interpreter /usr/local/opt/python3/bin/python3.6 which you have had installed and later removed. To fix the script reinstall virtualenv package using an existing Python:

pip3 install -U virtualenv
like image 22
phd Avatar answered Nov 04 '22 07:11

phd