![“错误:无法创建‘/usr/local/lib/python2.7/dist-packages/textstat’:权限被拒绝”](https://linux22.com/image/975697/%E2%80%9C%E9%94%99%E8%AF%AF%EF%BC%9A%E6%97%A0%E6%B3%95%E5%88%9B%E5%BB%BA%E2%80%98%2Fusr%2Flocal%2Flib%2Fpython2.7%2Fdist-packages%2Ftextstat%E2%80%99%EF%BC%9A%E6%9D%83%E9%99%90%E8%A2%AB%E6%8B%92%E7%BB%9D%E2%80%9D.png)
当我尝试在 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...