LoginSignup
0
0

More than 5 years have passed since last update.

PYTHONPATHエラー@mac with brew

Last updated at Posted at 2018-08-15

pyenvが壊れた?PYTHONPATHエラーでPython3.xが起動時に2.xのモジュールを参照する件

を参考にした作業報告

$ pip install http-prompt
Error in sitecustomize; set PYTHONVERBOSE for traceback:
KeyError: 'PYTHONPATH'
Traceback (most recent call last):
  File "/Users/ogawakiyoshi/.pyenv/versions/anaconda3-4.3.0/bin/pip", line 7, in <module>
    from pip import main
ImportError: cannot import name 'main'

ここで、ネットで「Error in sitecustomize; set PYTHONVERBOSE for traceback:
KeyError: 'PYTHONPATH'」で検索して出てきたのが上記Qiita記事。

brew doctor

$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
  /Users/ogawakiyoshi/.pyenv/shims/icu-config
  /Users/ogawakiyoshi/.pyenv/shims/libpng16-config
  /Users/ogawakiyoshi/.pyenv/shims/python3.6m-config
  /Users/ogawakiyoshi/.pyenv/shims/python-config
  /Users/ogawakiyoshi/.pyenv/shims/python3-config
  /Users/ogawakiyoshi/.pyenv/shims/python3.6-config

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
  /usr/local/lib/BugpointPasses.dylib
  /usr/local/lib/LLVMHello.dylib
  /usr/local/lib/libLTO.dylib

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
  /usr/local/include/llvm-c/Analysis.h
  /usr/local/include/llvm-c/BitReader.h
  /usr/local/include/llvm-c/BitWriter.h
  /usr/local/include/llvm-c/Core.h
 (中略)
  /usr/local/include/llvm/XRay/Graph.h
  /usr/local/include/llvm/XRay/InstrumentationMap.h
  /usr/local/include/llvm/XRay/Trace.h
  /usr/local/include/llvm/XRay/XRayRecord.h
  /usr/local/include/llvm/XRay/YAMLXRayRecord.h

Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected static libraries:
  /usr/local/lib/libLLVMAArch64AsmParser.a
  /usr/local/lib/libLLVMAArch64AsmPrinter.a
  /usr/local/lib/libLLVMAArch64CodeGen.a
  /usr/local/lib/libLLVMAArch64Desc.a
(中略)
  /usr/local/lib/libLLVMXCoreDisassembler.a
  /usr/local/lib/libLLVMXCoreInfo.a
  /usr/local/lib/libLLVMXRay.a
  /usr/local/lib/libLLVMipo.a

Warning: Broken symlinks were found. Remove them with `brew prune`:
  /usr/local/bin/docker-credential-osxkeychain.backup
  /usr/local/bin/gengal
  /usr/local/bin/hyperkit.backup
  /usr/local/bin/notary.backup
  /usr/local/bin/regmerge
  /usr/local/bin/regview
  /usr/local/bin/scan
  /usr/local/bin/senddoc
  /usr/local/bin/ui-previewer
  /usr/local/bin/uno
  /usr/local/bin/unoinfo
  /usr/local/bin/unopkg
  /usr/local/bin/uri-encode
  /usr/local/bin/vpnkit.backup
  /usr/local/bin/xpdfimport
  /usr/local/share/man/man1/scan.1

$ brew prune
Pruned 16 symbolic links and 7 directories from /usr/local

$ cat $HOME/.local/lib/python3.6/site-packages/homebrew.pth
import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")

homebrew.pth編集

記事の指摘どおり、3.6で2.7を参照している。
記事との唯一の違いは、コメントや削除するのではなく、2.7を3.6に書き換えた。もし、3.6に有効なデータが他にも蓄積されたときに役立つかもと思い。

これが新たなエラーを産んだら報告します。

$ vi $HOME/.local/lib/python3.6/site-packages/homebrew.pth
$ cat $HOME/.local/lib/python3.6/site-packages/home-brew.pth
import site; site.addsitedir("/usr/local/lib/python3.6/site-packages")

確認

$ pip install http-prompt
Collecting http-prompt
  Downloading https://files.pythonhosted.org/packages/16/7b/3abed965ed0fa41c532af1fe1afeedbf924926a881fa03c0a302625d0da8/http_prompt-0.11.2-py2.py3-none-any.whl
Collecting parsimonious>=0.6.2 (from http-prompt)
  Downloading https://files.pythonhosted.org/packages/02/fc/067a3f89869a41009e1a7cdfb14725f8ddd246f30f63c645e8ef8a1c56f4/parsimonious-0.8.1.tar.gz (45kB)
    100% |████████████████████████████████| 51kB 2.9MB/s 
Collecting httpie>=0.9.2 (from http-prompt)
  Downloading https://files.pythonhosted.org/packages/5a/d9/7c2048e86575ff01d5a1e085d12f0ceef42594d56c6b6905ff87f79cf683/httpie-0.9.9-py2.py3-none-any.whl (74kB)
    100% |████████████████████████████████| 81kB 3.4MB/s 
Requirement already satisfied: six>=1.10.0 in /Users/ogawakiyoshi/.pyenv/versions/anaconda3-4.3.0/lib/python3.6/site-packages (from http-prompt)
Requirement already satisfied: click>=5.0 in /Users/ogawakiyoshi/.pyenv/versions/anaconda3-4.3.0/lib/python3.6/site-packages (from http-prompt)
Requirement already satisfied: Pygments>=2.1.0 in /Users/ogawakiyoshi/.pyenv/versions/anaconda3-4.3.0/lib/python3.6/site-packages (from http-prompt)
Requirement already satisfied: prompt-toolkit<2.0.0,>=1.0.0 in /Users/ogawakiyoshi/.pyenv/versions/anaconda3-4.3.0/lib/python3.6/site-packages (from http-prompt)
Requirement already satisfied: requests>=2.11.0 in /Users/ogawakiyoshi/.pyenv/versions/anaconda3-4.3.0/lib/python3.6/site-packages (from httpie>=0.9.2->http-prompt)
Requirement already satisfied: wcwidth in /Users/ogawakiyoshi/.pyenv/versions/anaconda3-4.3.0/lib/python3.6/site-packages (from prompt-toolkit<2.0.0,>=1.0.0->http-prompt)
Building wheels for collected packages: parsimonious
  Running setup.py bdist_wheel for parsimonious ... done
  Stored in directory: /Users/ogawakiyoshi/Library/Caches/pip/wheels/b7/8d/e7/a0e74217da5caeb3c1c7689639b6d28ddbf9985b840bc96a9a
Successfully built parsimonious
Installing collected packages: parsimonious, httpie, http-prompt
Successfully installed http-prompt-0.11.2 httpie-0.9.9 parsimonious-0.8.1
You are using pip version 9.0.3, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 512kB/s 
Installing collected packages: pip
  Found existing installation: pip 9.0.3
    Uninstalling pip-9.0.3:
      Successfully uninstalled pip-9.0.3
Successfully installed pip-18.0

ありがとうございました。

文書履歴(document history)

ver. 0.10 初稿 20180815

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0