pip安装html5lib包的时候报一下错误:

➜  /test sudo  pip install html5lib

The directory '/Users/lele/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

The directory '/Users/lele/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

Collecting html5lib

  Downloading html5lib-1.0.1-py2.py3-none-any.whl (117kB)

    100% |████████████████████████████████| 122kB 61kB/s

Requirement already satisfied: webencodings in /Library/Python/2.7/site-packages (from html5lib)

Collecting six>=1.9 (from html5lib)

  Downloading six-1.11.0-py2.py3-none-any.whl

Installing collected packages: six, html5lib

  Found existing installation: six 1.4.1

    DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.

    Uninstalling six-1.4.1:

Exception:

Traceback (most recent call last):

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main

    status = self.run(options, args)

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run

    prefix=options.prefix_path,

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install

    requirement.uninstall(auto_confirm=True)

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall

    paths_to_remove.remove(auto_confirm)

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove

    renames(path, new_path)

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames

    shutil.move(old, new)

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move

    copy2(src, real_dst)

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2

    copystat(src, dst)

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat

    os.chflags(dst, st.st_flags)

OSError: [Errno 1] Operation not permitted: '/tmp/pip-L0B9DH-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'


这是因为OS X El Capitan发行时已经安装了六个1.4.1,当它试图卸载它时(因为awscli依赖于botocore,botocore依赖于python-dateutil,python-dateutil依赖于六> = 1.5)因为系统完整性保护甚至不允许root修改这些目录。

理想情况下,点应该跳过卸载这些项目,因为他们没有安装到他们安装到一个特殊的苹果目录的网站包。但是,即使点击跳过卸载这些项目,并安装六个站点包,我们会遇到另一个错误,苹果把他们预先安装的东西早于sys.path站点包。


解决办法:

➜  /test sudo pip install --ignore-installed six

The directory '/Users/lele/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

The directory '/Users/lele/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

Collecting six

  Downloading six-1.11.0-py2.py3-none-any.whl

Installing collected packages: six

Successfully installed six-1.11.0

➜  /test sudo  pip install html5lib

The directory '/Users/lele/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

The directory '/Users/lele/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

Collecting html5lib

  Downloading html5lib-1.0.1-py2.py3-none-any.whl (117kB)

    100% |████████████████████████████████| 122kB 137kB/s

Requirement already satisfied: webencodings in /Library/Python/2.7/site-packages (from html5lib)

Requirement already satisfied: six>=1.9 in /Library/Python/2.7/site-packages (from html5lib)

Installing collected packages: html5lib

Successfully installed html5lib-1.0.1