`python3.7: bad interpreter: No such file or directory`

After a few hours, one solution was to install virtualenv again with pip, then remove it with pip:

$ ls -la /usr/local/bin/virtualenv
-rwxr-xr-x  1 user  brew  232 29 Nov 17:06 /usr/local/bin/virtualenv
$ pip install virtualenv
...
$ pip uninstall virtualenv
...
$ which virtualenv
$ ls -la /usr/local/bin/virtualenv
ls: /usr/local/bin/virtualenv: No such file or directory

And then install it again with pip3:

$ pip3 install virtualenv
Collecting virtualenv
...
Installing collected packages: virtualenv
Successfully installed virtualenv-16.1.0

Notice the use of pip3, and not pip, unlike this link, pointed to by TensorFlow.

And now creating the virtual environment works:

$ virtualenv --system-site-packages -p python3 ./venv
Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.6'
New python executable in ~/venv/bin/python3
Also creating executable in ~/venv/bin/python
Installing setuptools, pip, wheel...
done.

I created a symlink instead of copy.

brew install [email protected]
ln -s /usr/local/opt/[email protected]/bin/python3.7 /usr/local/opt/python/bin/python3.7

In my case, I had installed pipenv on MacOS with:

brew install pipenv

It was trying to use Python 3.6 instead of the 3.7 I actually had.

So I solved the issue by uninstalling:

brew uninstall pipenv

...then installing again with pip:

pip3 install pipenv