我在macOS High Sierra上通过pip命令安装youtube-dl时遇到错误

时间:2017-12-05 17:39:51

标签: python terminal youtube-dl macos-high-sierra discord.py

长话短说,我正在创建一个不和谐机器人,我需要youtube-dl才能这样做。当我在终端上安装它时,我使用了命令

pip install youtube-dl

我得到了这个

Collecting youtube-dl
  Using cached youtube_dl-2017.12.2-py2.py3-none-any.whl
Installing collected packages: youtube-dl
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/youtube_dl'

我真的不知道如何制作这个或天气,或者不是它在高山脉中的pip命令本身就是一个错误。任何帮助,将不胜感激。谢谢!

2 个答案:

答案 0 :(得分:2)

您正在获得权限被拒绝,因为当前用户没有必要的权限,因此请使用sudo以及您的命令,如下所示:

sudo pip install youtube-dl

或使用root用户运行终端并运行命令。

答案 1 :(得分:1)

我建议您更改系统Python,而是使用homebrew安装Python,然后安装youtube-dl

brew install python
brew install youtube-dl