【问题标题】:Python ImportError while using youtube-dl by php通过 php 使用 youtube-dl 时出现 Python ImportError
【发布时间】:2014-03-28 15:07:03
【问题描述】:

Traceback(最近一次调用最后一次):文件“/usr/bin/youtube-dl”,行 3、在导入youtube_dl文件 “/usr/lib/python2.7/dist-packages/youtube_dl/init.py”,第 65 行,在 从 .utils 导入(文件 “/usr/lib/python2.7/dist-packages/youtube_dl/utils.py”,第 18 行,在 在 import _ssl 中导入 ssl 文件“/usr/lib/python2.7/ssl.py”,第 61 行 #如果我们不能导入它,让错误传播 ImportError: /usr/lib/python2.7/lib-dynload/_ssl.x86_64-linux-gnu.so: symbol GENERAL_NAME_free,版本 OPENSSL_1.0.0 未在文件中定义 libcrypto.so.1.0.0 与链接时间参考

我使用的命令

youtube-dl --max-quality 2180 --write-thumbnail -x --audio-format mp3 -c -o "/home/bahaa/%(id)s.%(ext)s" https://www.youtube.com/watch?v=xFQFMSNZW08&list=RDV-jLo0Ovems

我正在使用的 php 代码

<?php
    $url = 'https://www.youtube.com/watch?v=xFQFMSNZW08&list=RDV-jLo0Ovems';
    //escapeshellarg
    $string = ('youtube-dl --max-quality 2180 --write-thumbnail -x --audio-format mp3 -c -o "/home/bahaa/%(id)s.%(ext)s" https://www.youtube.com/watch?v=xFQFMSNZW08&list=RDV-jLo0Ovems');

    $descriptorspec = array(
        0 => array("pipe", "r"),  // stdin
        1 => array("pipe", "w"),  // stdout
        2 => array("pipe", "w"),  // stderr
    );

    $process = proc_open($string, $descriptorspec, $pipes);
    $stdout = stream_get_contents($pipes[1]);
    fclose($pipes[1]);
    $stderr = stream_get_contents($pipes[2]);
    fclose($pipes[2]);
    $ret = proc_close($process);
    echo json_encode(
        array(
            'status' => $ret,
            'errors' => str_replace("\n", "<br />", $stderr."<hr />"),
            'output' => $stdout,
        )
    );
?>

【问题讨论】:

  • 直接从命令行调用youtube-dl是否也出现同样的错误?
  • 不,我不能正常工作

标签: php python ubuntu ssl xampp


【解决方案1】:

嗨,我终于找到了解决方案! 首先,你能告诉我你的服务器配置吗?我正在使用 XAMPP,就我而言,Apache 使用的“Python”及其库与我的 ubuntu 使用的不同,因此我将 Python3 构建并安装到 /opt/lampp/bin 并自己构建 openssl。您可以从其网站下载 openssl1.0.1 并通过“./config shared”对其进行配置以构建 .so 文件。 接下来将 libssl.so* 和 libcrypto.so*(总共 4 个文件)复制到 /opt/lampp/lib(这是 LD_LIBRARY_PATH 指向的位置)并立即重新启动 apache 对我有用,希望对你有帮助

【讨论】:

  • 嘿,你最近怎么样?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-05-19
  • 2023-03-29
  • 2015-12-23
  • 2014-12-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多