I installed Python, pip3, and virtualenv as in this guide for TensorFlow:
brew install python pip3 install -U virtualenv Then I was able to create a virtual environment with:
virtualenv --system-site-packages -p python3 ./venv Then I tried installing TensorFlow with
pip install --upgrade tensorflow but it failed because TensorFlow is not yet compatible with Python 3.7. So I removed Python 3.7 with brew remove python and installed 3.6.7 from an installer. But running the same virtualenv command now fails:
$ virtualenv --system-site-packages -p python3 ./venv -bash: /usr/local/bin/virtualenv: /usr/local/opt/python/bin/python3.7: bad interpreter: No such file or directory $ which python3 /Library/Frameworks/ So the virtualenv link to the executable lists the newest Python version, even after removal.
Furthermore, virtualenv lists brew as the user group, which is also confusing:
$ ls -la /usr/local/bin/virtualenv -rwxr-xr-x 1 user brew 232 29 Nov 17:06 /usr/local/bin/virtualenv I've tried uninstalling virtualenv with both pip and pip3 and I get:
Skipping virtualenv as it is not installed. How can I fix this issue?
7 Answers
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/ Using base prefix '/Library/Frameworks/ 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 python@3.7 ln -s /usr/local/opt/python@3.7/bin/python3.7 /usr/local/opt/python/bin/python3.7 0In 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 1Try installing python@3.7 via homebrew and then cping that installation into the directory the program expects to find it.
brew install python@3.7 cp -r /usr/local/opt/python@3.7/bin/python3.7 /usr/local/opt/python/bin/python3.7 1That solved the problem in my case: (my env file is called .venv)
mv .venv .venv_old python3.7 -m venv .venv source .venv/bin/activate pip install wheel pip install --upgrade pip wheel setuptools pip install -r requirements.txt In my case, I was on MacOS and I had python3.9 installed, but virtualenv was installed using python3.7 and at some point I uninstalled python3.7.
$ /usr/local/bin/virtualenv --version -bash: /usr/local/bin/virtualenv: /usr/local/opt/python/bin/python3.7: bad interpreter: No such file or directory However, my python version:
$ which python3.9 /usr/local/bin/python3.9 No amount of pip or pip3 install/uninstall/install virtualenv worked for me. Finally I did the following:
$ python3.9 -m pip install --user virtualenv Collecting virtualenv Using cached virtualenv-20.4.6-py2.py3-none-any.whl (7.2 MB) <snip> Successfully installed appdirs-1.4.4 distlib-0.3.1 filelock-3.0.12 virtualenv-20.4.6 And then
$ /usr/local/bin/virtualenv --version virtualenv 20.4.6 from <mypath> Yay!!
In my case what solved the situation was adding a line at the end of the ~/.zshrc file:
export PATH=/usr/local/opt/python/libexec/bin:$PATH hope it helps.