I am on mac (mojave osx 10.14) and admittedly I have a pretty messed up python environment.
Recently I have been getting multiple errors such as:
zsh: /usr/local/bin/pip: bad interpreter: /usr/local/opt/python/bin/python3.6: no such file or directory
zsh: /usr/local/bin/alembic: bad interpreter: /usr/local/opt/python/bin/python3.6: no such file or directory
zsh: /usr/local/bin/pytest: bad interpreter: /usr/local/opt/python/bin/python3.6: no such file or directory
This is the case even with creating and entering a virtualenv to work inside of.
In this specific case, I need a python3 virtual env.
When I which python
outside the environment, I get /usr/local/bin/python
and python -v
= Python 2.7.15
Outside this virtualenv, I get these bad interpreter errors.
I create a virtualenv for python3 with virtualenv -p python3 .venv
Without even installing anything, I still get
zsh: /usr/local/bin/alembic: bad interpreter: /usr/local/opt/python/bin/python3.6: no such file or directory
zsh: /usr/local/bin/pytest: bad interpreter: /usr/local/opt/python/bin/python3.6: no such file or directory
If I pip uninstall alembic
and pip3 uninstall alembic
, I get the bad interpreter error still.
I have no idea where it might still be installed and not sure where to start on how to clean up my environment. Would like a fresh start but I don't know if that's possible.
You have removed (uninstalled) /usr/local/opt/python/bin/python3.6
and the interpreter is used as the shebang in /usr/local/bin/alembic
, /usr/local/bin/pytest
and perhaps other scripts. The best way to fix them is to reinstall them with a different interpreter. For example:
/usr/bin/python3.6 -m pip install -U alembic pip pytest
/usr/bin/python3.6
is only an example here.
My problem (Mac OS 14.4.1) was with Python 2.7 version, which was missing symlinks. I've solved it by the problem by running:
brew link --overwrite python
As mentioned here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.