安装Python包时出现Errno 13错误

3
我是一个新手程序员,刚刚在我的笔记本电脑上下载了Ubuntu。我遇到的问题是当我尝试从终端安装Python包tabulate(https://pypi.python.org/pypi/tabulate)时,它显示一个错误告诉我我没有权限这样做。
    kai@kai-HP-Notebook:~$ pip install tabulate
Downloading/unpacking tabulate
  Downloading tabulate-0.7.5.tar.gz
  Running setup.py (path:/tmp/pip_build_kai/tabulate/setup.py) egg_info for package tabulate

Installing collected packages: tabulate
  Running setup.py install for tabulate
    error: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/tabulate.py'
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_kai/tabulate/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-If5xKf-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

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

running install_lib

copying build/lib.linux-x86_64-2.7/tabulate.py -> /usr/local/lib/python2.7/dist-packages

error: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/tabulate.py'

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

我做错了什么?我相信这是一个很容易解决的问题。

3
请使用sudo pip install tabulate进行安装。 - JRodDynamite
或者 pip install --user tabulate - Pawel Miech
哇,谢谢,这比我想象中的还要容易。 - user6041520
1
使用 virtualenv 可以避免使用 sudo 权限。参考:https://virtualenv.pypa.io/en/latest/userguide.html - Rahul K P
@JasonEstibeiro 请在下面的“答案”中添加您的答案,以便未来的人们可以查看正确答案的历史记录 :) - Sir. Hedgehog
1个回答

2

由@JRodDynamite回答:使用

sudo pip install tabulate

1
请勿从注释中复制粘贴! - Rahul K P
1
请勿从评论中复制。 - Rahul K P
请向回答您评论的那个人提出请求,让他将其作为答案发布,这样他也可以从他的回答中获得声望加分。 - Sir. Hedgehog
3
@hedgehog - 没关系,让他把它发布为答案。把这当作我的欢迎礼物。欢迎来到SO! :) - JRodDynamite

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接