Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run yt-dlp, report ImportError: cannot import name 'pbkdf2_hmac' from 'hashlib' #8477

Closed
10 of 11 tasks
cosysun opened this issue Oct 30, 2023 · 6 comments
Closed
10 of 11 tasks
Labels
question Question

Comments

@cosysun
Copy link

cosysun commented Oct 30, 2023

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I intentionally remove or skip any mandatory* field

Checklist

Region

china

Provide a description that is worded well enough to be understood

when i run yt-dlp,report as fellow:

Traceback (most recent call last):
File "/root/python3-env/bin/yt-dlp", line 5, in
from yt_dlp import main
File "/root/python3-env/lib/python3.12/site-packages/yt_dlp/init.py", line 19, in
from .cookies import SUPPORTED_BROWSERS, SUPPORTED_KEYRINGS
File "/root/python3-env/lib/python3.12/site-packages/yt_dlp/cookies.py", line 19, in
from hashlib import pbkdf2_hmac
ImportError: cannot import name 'pbkdf2_hmac' from 'hashlib' (/usr/local/lib/python3.12/hashlib.py)

pbkdf2_hmac is only added by python2.7,python3.12 is not contain this module,have anyone the same problem, how can i fix it,thanks

system info as fellow:
python version: 3.12
system version:18.04.1-Ubuntu
yt-dlp version:latest

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • If using API, add 'verbose': True to YoutubeDL params instead
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

Traceback (most recent call last):
  File "/root/python3-env/bin/yt-dlp", line 5, in <module>
    from yt_dlp import main
  File "/root/python3-env/lib/python3.12/site-packages/yt_dlp/__init__.py", line 19, in <module>
    from .cookies import SUPPORTED_BROWSERS, SUPPORTED_KEYRINGS
  File "/root/python3-env/lib/python3.12/site-packages/yt_dlp/cookies.py", line 19, in <module>
    from hashlib import pbkdf2_hmac
ImportError: cannot import name 'pbkdf2_hmac' from 'hashlib' (/usr/local/lib/python3.12/hashlib.py)
@cosysun cosysun added site-bug Issue with a specific website triage Untriaged issue labels Oct 30, 2023
@bashonly
Copy link
Member

Per python 3.12 changelog:

hashlib

Remove the pure Python implementation of hashlib’s hashlib.pbkdf2_hmac(), deprecated in Python 3.10. Python 3.10 and newer requires OpenSSL 1.1.1 (PEP 644): this OpenSSL version provides a C implementation of pbkdf2_hmac() which is faster. (Contributed by Victor Stinner in gh-94199.)

Do you have OpenSSL >=1.1.1 installed?

@bashonly bashonly added question Question and removed site-bug Issue with a specific website triage Untriaged issue labels Oct 30, 2023
@bashonly bashonly closed this as completed Nov 5, 2023
@cosysun
Copy link
Author

cosysun commented Nov 8, 2023

i resloved it, if you upgrade openssl, you should rebuild python below
./configure --with-openssl=/usr/local/openssl
make
make install

@connors89
Copy link

I'm sorry I don't know what you mean by this. I have the same issue but do I copy that in my terminal? I am on macOS with OpenSSl 3.2.1

@bashonly
Copy link
Member

bashonly commented Apr 9, 2024

@connors89 can you give more details? e.g. when did this start happening for you, how did you install yt-dlp, what version are you trying to run?

@connors89
Copy link

connors89 commented Apr 9, 2024

I am trying to package yt-dlp into a standalone GUI using py2app, when I get my application, I double click and get a launch error, when I go into app contents and run the UNIX executable file, it gives the same error as the issue name. I believe I pip installed yt-dlp? (it was some time ago) it is located at /Library/Frameworks/Python.framework/Versions/3.12/bin/yt-dlp and is version 2024.03.10

@bashonly
Copy link
Member

bashonly commented Apr 9, 2024

@connors89 Looks like openssl is not being included in your py2app build? This advice might be relevant: ronaldoussoren/py2app#308 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question
Projects
None yet
Development

No branches or pull requests

3 participants