使用 pip 安装 edx-dl 包时出现的问题

使用 pip 安装 edx-dl 包时出现的问题

我想从 YouTube 和 edX 批量下载一些讲座,所以我看了看这里的项目:

https://github.com/coursera-dl/edx-dl

我正在使用上面链接中建议的 Python 3.4.3

$ python
Python 3.4.3 (default, Oct 14 2015, 20:28:29) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.

现在我尝试了以下命令:

  1. pip install youtube-dl

结果如下:

sparsh@sparsh-Inspiron-3558:~$ pip install youtube-dl
Downloading/unpacking youtube-dl
  Downloading youtube_dl-2016.7.24-py2.py3-none-any.whl (1.4MB): 1.4MB downloaded
Installing collected packages: youtube-dl
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1436, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 672, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 902, in move_wheel_files
    pycompile=self.pycompile,
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 206, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 193, in clobber
    os.makedirs(destsubdir)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/youtube_dl-2016.7.24.dist-info'

Storing debug log for failure in /home/sparsh/.pip/pip.log
sparsh@sparsh-Inspiron-3558:~$ pip install --upgrade youtube-dl
Downloading/unpacking youtube-dl
  Downloading youtube_dl-2016.7.24-py2.py3-none-any.whl (1.4MB): 1.4MB downloaded
Installing collected packages: youtube-dl
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1436, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 672, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 902, in move_wheel_files
    pycompile=self.pycompile,
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 206, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 193, in clobber
    os.makedirs(destsubdir)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/youtube_dl-2016.7.24.dist-info'

Storing debug log for failure in /home/sparsh/.pip/pip.log
  1. 当我尝试该命令时: pip install edx-dl

结果如下:

    sparsh@sparsh-Inspiron-3558:~$ pip install edx-dl
Downloading/unpacking edx-dl
  Downloading edx-dl-0.1.2.tar.gz
  Running setup.py (path:/tmp/pip_build_sparsh/edx-dl/setup.py) egg_info for package edx-dl

Downloading/unpacking beautifulsoup4>=4.1.3 (from edx-dl)
  Downloading beautifulsoup4-4.5.0-py2-none-any.whl (83kB): 83kB downloaded
Downloading/unpacking html5lib>=1.0b2 (from edx-dl)
  Downloading html5lib-1.0b10.tar.gz (245kB): 245kB downloaded
  Running setup.py (path:/tmp/pip_build_sparsh/html5lib/setup.py) egg_info for package html5lib
    html5lib requires setuptools version 18.5 or above; please upgrade before installing (you have 3.3)
    Complete output from command python setup.py egg_info:
    html5lib requires setuptools version 18.5 or above; please upgrade before installing (you have 3.3)

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_sparsh/html5lib
Storing debug log for failure in /home/sparsh/.pip/pip.log

pip 版本是

sparsh@sparsh-Inspiron-3558:~$ pip --version
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)

我该如何解决这个问题?如果有更好的方法可以批量下载 edX 的讲座,请分享。

答案1

pip是 python2 文件。要将 pip 与 python3 一起使用:安装并使用 pip3。

sudo apt install python3-pip ( provides /usr/bin/pip3 )

pip3 install youtube-dl

相关内容