I use zsh with oh my zsh, i have installed flake8 using 'pip install flake8' and i changed path to flake8:
export PATH="/opt/homebrew/lib/python3.10/site-packages:$PATH"
example of error
❯ python --version
Python 3.10.1
❯ pip --version
pip 21.3.1 from /opt/homebrew/lib/python3.10/site-packages/pip (python 3.10)
❯ flake8 --version
zsh: permission denied: flake8
❯ python -m flake8 --version
4.0.1 (flake8-broken-line: 0.4.0, flake8-return: 1.1.3, flake8_isort: 4.1.1, mccabe: 0.6.1,
naming: 0.12.1, pycodestyle: 2.8.0, pyflakes: 2.4.0) CPython 3.10.1 on Darwin
python -m flake8 --version
is works, but flake8 --version
doesn't work.
How to fix this error?
You shouldn't have done
export PATH="/opt/homebrew/lib/python3.10/site-packages:$PATH"
That is only where the python modules reside. I.e. the executable flake8
does not live in that folder, only a directory with that name containing the pyhton sources exists in that folder. That is where your error is comming from. When you type flake8
in your zsh
, the only thing that is found in the PATH is that directory, which cannot be executed.
You need to find out where pip
has installed the actual executable and (possibly) add that location to path. You can check the location returned by
echo `python -m site --user-base`/bin