0

Long story short, I am creating a discord bot and I need youtube-dl to do so. When I went to install it on terminal, I used the command

pip install youtube-dl

and I got this

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'

I don't really know what to make of this or weather or not it is a bug with the pip command itself in High Sierra. Any help would be appreciated. Thanks!

sarora
  • 512
  • 1
  • 6
  • 11
  • you have to use `sudo pip install` to install a package to the OS's python instance, or install a separate python instance for your use – Dalvenjia Dec 05 '17 at 17:43
  • `Permission denied` means you don't have enough privileges to access some path on your computer. What do you do in such cases? Try to obtain higher privileges. How do you do that? You can either log in as root (which may be dangerous _AF_ if you aren't experienced enough) or just _use `sudo`_. – ForceBru Dec 05 '17 at 17:43

2 Answers2

2

You're getting permission denied as current user do not have required permission therefore use sudo along with your command as follows:

sudo pip install youtube-dl

or run terminal with root user and run your command.

Mahesh Karia
  • 2,045
  • 1
  • 12
  • 23
1

I would recommend that you not change the system Python, but instead use homebrew to install Python, then install youtube-dl:

brew install python
brew install youtube-dl
Joe McMahon
  • 3,266
  • 21
  • 33