无法在Mac OS El Capitan上安装nltk

pro*_*ray 25 python nltk python-2.7

sudo pip install -U nltk按照nltk文档的建议做了.但是,我得到以下输出:

Collecting nltk
  Downloading nltk-3.0.5.tar.gz (1.0MB)
    100% |????????????????????????????????| 1.0MB 516kB/s 
Collecting six>=1.9.0 (from nltk)
  Downloading six-1.9.0-py2.py3-none-any.whl
Installing collected packages: six, nltk
  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/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 311, in run
    root=options.root_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 640, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 716, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 125, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 315, 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-7dp3on-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
Run Code Online (Sandbox Code Playgroud)

基本上,它无法从1.4.1升级到1.9.0.我试图单独做,但得到了同样的错误.

我提到了El Capitan,因为有些人在El Capitan上遇到其他python安装的问题,我想知道这是否是由于这个原因.

有谁知道如何解决这个问题?

nvg*_*g58 38

以下是我解决问题的方法:

首先,安装Xcode CLI:

xcode-select --install
Run Code Online (Sandbox Code Playgroud)

然后重新安装Python:

sudo brew reinstall python
Run Code Online (Sandbox Code Playgroud)

最后,安装nltk:

sudo pip install -U nltk
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你 :)

  • 酿造时不需要"sudo",也不需要"pip".在其他帖子中有解决方案会导致禁用安全设置,但这很危险.这个正确的故障排除:) (2认同)

Sac*_*ous 17

我知道那里有很多'酿造助推器',但你不应该使用另一个python来做一些基本的东西.如果pip在/ System中找到依赖关系,正如他们在南方公园所说的那样,你将会度过一个糟糕的时光.如果您不需要在系统范围内进行此更改,则可以pip install --user <package>添加$HOME/Library/Python/2.7/bin到shell路径(通过~/.bash_profile等).


小智 8

这两个都导致六个版本1.41:

pip install --ignore-installed six

pip install awsebcli --upgrade --ignore-installed six

brew解决方案是有意义的,imo.如果Apple需要自己的El Capitan Python副本,它可以拥有它.我现在在这里:/usr/local/bin/python