Python 如何在OSX上安装pyperclip

Python 如何在OSX上安装pyperclip,python,macos,pip,Python,Macos,Pip,当我使用命令“pip install pyperclip”时,它给出了这个错误 creating /Library/Python/2.7/site-packages/pyperclip error: could not create '/Library/Python/2.7/site-packages/pyperclip': Permission denied ---------------------------------------- Command "/usr/bin/pyth

当我使用命令“pip install pyperclip”时,它给出了这个错误

creating /Library/Python/2.7/site-packages/pyperclip
    error: could not create '/Library/Python/2.7/site-packages/pyperclip': Permission denied

----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/ts/tdt25dd52pg6ymt1tc1djd540000gn/T/pip-build-QWGKB1/pyperclip/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/ts/tdt25dd52pg6ymt1tc1djd540000gn/T/pip-sfvxg3-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/ts/tdt25dd52pg6ymt1tc1djd540000gn/T/pip-build-QWGKB1/pyperclip/

为什么我没有权限。

当您遇到错误
权限被拒绝时
是因为您试图使用普通命令访问根目录。因此,尝试以root用户身份运行该命令以消除
permissindenied
错误。运行
sudo命令
sudopip安装pyperclip

sudo pip安装pyperclip

现在,如果它抛出一些访问拒绝错误,请尝试以下操作:

sudo pip-H安装pyperclip


如果要安装到系统软件包中,则需要以root
sudo pip install…
身份运行。或者,创建一个
virtualenv
,并作为用户安装在虚拟环境中。Ahhh@安:你是最棒的。谢谢你抽出时间。