環境: Mac Mojave, Homebrew
Homebrewでインストールしたpip3がいつの間にかパスが通っていなくて使えなくなっていた。python3やモジュールのimportは正常で可能。
$ brew reinstall python
とすると、
...
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall python`
と警告がでた、ここでファイルのPermission Deniedが出たいたので、ひとつずつdeniedされたファイルが入っているディレクトリを
$ chown -R username DeniedDirectoryPath
としていき所有者を変えていくと、postinstallに成功した。(前回のインストール時に変なことをして、所有者がrootになった?)
このタイミングで、pip3へのパスが通ったが、pip listしようとすると、
ValueError: ("Missing 'Version:' header and/or METADATA file at path: /usr/local/lib/python3.7/site-packages/-ip-19.0.1.dist-info/METADATA", Unknown [unknown version] (/usr/local/lib/python3.7/site-packages))
とエラーが出た。
pipでAttributeError: _versionが出たときの対応を参考に、-ip-19.0.1.dist-infoをip-19.0.1.dist-infoに名前を変更し、再び、pip listすると、
No such file or directory: '/usr/local/lib/python3.7/site-packages/ip-19.0.1.dist-info/METADATA'
とエラーが出たので、ip-19.0.1.dist-info/pip-19.0.1.dist-info内のファイルをip-19.0.1.dist-info直下にコピーしたら、これでpip3が正常に動くようになった。
PC中にファイルがばらまかれていて、フォルダの依存関係がてんで分かりません。再起動時にlogが消えてしまったので具体的なエラーは消えてしまいましたが、誰かの救いになれば幸いです。