“错误:无法创建‘/usr/local/lib/python2.7/dist-packages/textstat’:权限被拒绝”

“错误:无法创建‘/usr/local/lib/python2.7/dist-packages/textstat’:权限被拒绝”

当我尝试在 ubuntu 14.04 LTS 上安装textstat(一个 python 模块)时,通过pip..我得到了::

anupam@JAZZ:~$ pip install textstat
Downloading/unpacking textstat
  Downloading textstat-0.1.6.tar.gz
  Running setup.py (path:/tmp/pip_build_anupam/textstat/setup.py) egg_info for package textstat

Installing collected packages: textstat
  Running setup.py install for textstat
    error: could not create '/usr/local/lib/python2.7/dist-packages/textstat': Permission denied
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_anupam/textstat/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Y0Ua2o-record/install-record.txt --single-version-externally-managed --compile:
    running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

creating build/lib.linux-x86_64-2.7/textstat

copying textstat/word_list.py -> build/lib.linux-x86_64-2.7/textstat

copying textstat/__init__.py -> build/lib.linux-x86_64-2.7/textstat

copying textstat/textstat.py -> build/lib.linux-x86_64-2.7/textstat

running install_lib

creating /usr/local/lib/python2.7/dist-packages/textstat

error: could not create '/usr/local/lib/python2.7/dist-packages/textstat': Permission denied

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_anupam/textstat/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Y0Ua2o-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_anupam/textstat
Storing debug log for failure in /home/anupam/.pip/pip.log
anupam@JAZZ:~$ 

我该如何解决这个问题?我应该更改 /usr/local/lib/python2.7/dist-packages 的权限吗?

答案1

只需使用须藤安装 Python 模块的命令/usr/local

sudo pip install textstat
[sudo] password for sylvain: 
Downloading/unpacking textstat
  Downloading textstat-0.1.6.tar.gz
  Running setup.py (path:/tmp/pip_build_root/textstat/setup.py) egg_info for package textstat

Installing collected packages: textstat
  Running setup.py install for textstat

Successfully installed textstat
Cleaning up...

相关内容