Python 系统找不到“edx dl”模块中指定的文件

Python 系统找不到“edx dl”模块中指定的文件,python,windows,edx,Python,Windows,Edx,我正在尝试使用这个Python模块 请原谅我的基本知识 安装了Anaconda 3 Windows 10,然后: pip安装edx dl pip安装--升级youtube dl 然后,为了获得课程: edx-dl-uuser@user.com--列出课程 edx-dl-uuser@user.com课程地址 然而,一旦下载真正开始,这一切都起作用了: 获取SSL/连接错误:HTTP错误403:禁止 Fiddler显示它被Cloudfare阻止,我怀疑是由于用户代理 我安装了Fake_UserAge

我正在尝试使用这个Python模块

请原谅我的基本知识

安装了Anaconda 3 Windows 10,然后:

pip安装edx dl

pip安装--升级youtube dl

然后,为了获得课程:

edx-dl-uuser@user.com--列出课程

edx-dl-uuser@user.com课程地址

然而,一旦下载真正开始,这一切都起作用了: 获取SSL/连接错误:
HTTP错误403:禁止

Fiddler显示它被Cloudfare阻止,我怀疑是由于用户代理

我安装了Fake_UserAgent并添加:

from fake_useragent import UserAgent #added this


def edx_get_headers():
    """
    Build the Open edX headers to create future requests.
    """
    logging.info('Building initial headers for future requests.')

    headers = {
        'User-Agent': 'edX-downloader/0.01',
        'Accept': 'application/json, text/javascript, */*; q=0.01',
        'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
        'Referer': EDX_HOMEPAGE,
        'X-Requested-With': 'XMLHttpRequest',
        'X-CSRFToken': _get_initial_token(EDX_HOMEPAGE),
    }

    ua = UserAgent()   #added this
    headers['User-Agent'] = ua.ie #added this
然后,它下载了一个pdf和一个xls,但由于request.py添加了一个标题,因此又出现了另一个错误,因此在requests.py中添加了false,并注释掉了默认标题,如下所示

from fake_useragent import UserAgent
        ub = UserAgent()
        self.addheaders = [('User-Agent', ub.ie)] 
        # self.addheaders = [('User-Agent', self.version), ('Accept', '*/*')] [('User-Agent', self.version), ('Accept', '*/*')]
新错误如下所示。我不知道如何进一步排除故障。我怀疑它找不到文件/路径,可能是因为Windows

[download] https://youtube.com/watch?v=bKkrDLwDnDE => Downloaded\Implementing_ETL_with_SQL_Server_Integration_Services\02-Module_1__ETL_Processing\01-%(title)s-%(id)s.%(ext)s
Downloading video with URL https://youtube.com/watch?v=bKkrDLwDnDE from YouTube.
Traceback (most recent call last):
  File "edx-dl.py", line 6, in <module>
    edx_dl.main()
  File "c:\edx-dl-master\edx-dl-master\edx_dl\edx_dl.py", line 1080, in main
    download(args, selections, filtered_units, headers)
  File "c:\edx-dl-master\edx-dl-master\edx_dl\edx_dl.py", line 857, in download
    headers)
  File "c:\edx-dl-master\edx-dl-master\edx_dl\edx_dl.py", line 819, in download_unit
    headers)
  File "c:\edx-dl-master\edx-dl-master\edx_dl\edx_dl.py", line 801, in download_video
    skip_or_download(youtube_downloads, headers, args)
  File "c:\edx-dl-master\edx-dl-master\edx_dl\edx_dl.py", line 788, in skip_or_download
    f(url, filename, headers, args)
  File "c:\edx-dl-master\edx-dl-master\edx_dl\edx_dl.py", line 721, in download_url
    download_youtube_url(url, filename, headers, args)
  File "c:\edx-dl-master\edx-dl-master\edx_dl\edx_dl.py", line 761, in download_youtube_url
    execute_command(cmd, args)
  File "c:\edx-dl-master\edx-dl-master\edx_dl\utils.py", line 37, in execute_command
    subprocess.check_call(cmd)
  File "C:\Users\anton\Anaconda3\lib\subprocess.py", line 286, in check_call
    retcode = call(*popenargs, **kwargs)
  File "C:\Users\anton\Anaconda3\lib\subprocess.py", line 267, in call
    with Popen(*popenargs, **kwargs) as p:
  File "C:\Users\anton\Anaconda3\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Users\anton\Anaconda3\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
[下载]https://youtube.com/watch?v=bKkrDLwDnDE =>已下载\U ETL\U与\U SQL\U Server\U集成\U服务\02-Module\U 1\U ETL\U处理\01-%(标题)s-%(id)s.%(ext)s
使用URL下载视频https://youtube.com/watch?v=bKkrDLwDnDE 来自YouTube。
回溯(最近一次呼叫最后一次):
文件“edx dl.py”,第6行,在
edx_dl.main()
文件“c:\edx dl master\edx dl master\edx\U dl\edx\U dl.py”,第1080行,主目录
下载(参数、选择、筛选的单位、标题)
文件“c:\edx dl master\edx dl master\edx\U dl\edx\U dl.py”,第857行,下载
标题)
文件“c:\edx dl master\edx dl master\edx\U dl\edx\U dl.py”,第819行,下载单元
标题)
下载视频中的文件“c:\edx dl master\edx dl master\edx\U dl\edx\U dl.py”,第801行
跳过或下载(youtube下载、标题、参数)
文件“c:\edx dl master\edx dl master\edx\U dl\edx\U dl.py”,第788行,跳过或下载
f(url、文件名、标题、参数)
文件“c:\edx dl master\edx dl master\edx\U dl\edx\U dl.py”,第721行,在下载url中
下载\u youtube\u url(url、文件名、标题、参数)
文件“c:\edx dl master\edx dl master\edx\U dl\edx\U dl.py”,第761行,位于下载url中
执行_命令(cmd,args)
文件“c:\edx dl master\edx dl master\edx\U dl\utils.py”,第37行,在execute\U命令中
子进程检查调用(cmd)
文件“C:\Users\anton\Anaconda3\lib\subprocess.py”,第286行,在check\u调用中
retcode=call(*popenargs,**kwargs)
调用中第267行的文件“C:\Users\anton\Anaconda3\lib\subprocess.py”
将Popen(*popenargs,**kwargs)作为p:
文件“C:\Users\anton\Anaconda3\lib\subprocess.py”,第709行,在\uuu init中__
恢复信号,启动新会话)
文件“C:\Users\anton\Anaconda3\lib\subprocess.py”,第997行,在执行子进程中
startupinfo)
FileNotFoundError:[WinError 2]系统找不到指定的文件
与这里的问题相同,但是没有提供解决方案或帮助,所以我想我会在这里尝试


关于如何解决此问题的建议将不胜感激。

调试了代码,发现无法找到
youtube dl

检查echo
%PATH%
并意识到我有以下路径:

C:…\Anaconda3\
但不要到
C:…\Anaconda3\Scripts\(这是youtube_dl.exe的位置)

我已添加此路径,但未重新启动


重新启动,现已解决。

还有另一个简单的解决方案,无需使用
Fake\u UserAgent
,只需使用其他下载程序,如
wget

安装新的edx_dl

如果您使用的是Windows下载,请将其保存在H驱动器上

更改
下载\u url
功能如下:

def download_url(url, filename, headers, args):
    """
    Downloads the given url in filename.
    """

    if is_youtube_url(url):
        download_youtube_url(url, filename, headers, args)
    else:
    # jcline
        cmd = (["h:\wget.exe", url, '-c', '-O', filename, '--keep-session-cookies', '--no-check-certificate'])
        execute_command(cmd, args)
()