-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
AttributeError: 'HTMLParser' object has no attribute 'unescape' #778
Comments
Hi! I was receiving the exact same error, did some research and I discovered that in python 3.9.0 HTMLParser.unescape was removed, so I switched back to python 3.8 and it is working perfectly fine. Switching to a older version that is greater than 3.4 should work. Hope it helps! |
Thanks, that worked! |
Here is a patch without needing to downgrade to python3.8 coursera-dl/edx-dl@5490a99 works in linux. |
I tried copying the file into Coursera folder but did help got ImportError: cannot import name 'random_string' from 'coursera.utils' error |
@rm00-git how to go to previous version of python . Please tell me. Much needed. |
@rm00-git Thank you so much man. I really appretiate it. |
considering backward compatibility Python 3.9.0 changelog: https://docs.python.org/release/3.9.0/whatsnew/changelog.html
first thanks @zenny
|
Thanks, it worked! |
refer to ziko442's reply to fix the issue with coursera-dl, his reply is for edx-dl. |
If you modify coursera\utils.py to import html 3.9 Works. Suggest the dev team to implement this change. |
It worked for me on debian buster with bullseye testing repositories. |
Hi i did it and still getting" AttributeError: 'HTMLParser' object has no attribute 'unescape'" any idea what i can do more to solve it? |
@adirb1 Try also commenting out this line: from six.moves import html_parser And you need to replace two occurrences of |
I think there may be a problem with that change. Here, html.unescape() is only available from Python 3.4. Bellow that, it doesn't exist. So I think your code may not work on Python from 3.0 through 3.3. You might want to change the line:
to
I'm not using Python 3.3 (using 3.9), but only found your reply after having read about Python 3.4 as minimum, so thought you might want to correct the file. Thanks though. I'll go for that instead of hard-coding the new way as I was doing. |
The software works for me now using the CAUTH flag and ziko's instructions. Thank you so much. OS Name: Microsoft Windows 10 Enterprise
|
Pull request #789 should fix this issue... |
Worked in OSX Catalina as well. |
It works for me:
MAKE SURE YOU INSTALL IT FOR RIGHT PYTHON VERSION! (
|
sudo update-alternatives --config python3 |
Thanks |
This issue was fixed by pull request #789 (as mentioned above),As such, there is no reason to risk security hazards by resorting to replacing large amounts of code... |
If anybody using Coursera package, just do this if you can't fix the |
This is great. This works for Python 3.10.2 as well. |
This worked on my Mac OS X 11.6.3 with Python 3.9 as of today date except the path of utils.py is: /Users/<your_username>/opt/anaconda3/lib/python3.9/site-packages/coursera/utils.py I modified the file as per above link and I could complete downloading the few courses which were throwing the html parser error. I also had to get the CAUTH using Safari development tools/web inspector. Not very cool to have to crawl the internet to get it working but well worth the time saved to download all courses. The only thing which are not downloaded at all are all the readings contained in an iframe. |
I replaced util.py with #778 but still not working. There is an error saying "XXXX/python3.9/site-packages/coursera/utils.py", line 118, in clean_filename Not sure what went wrong. I already set h = html |
Fixed. Thanks a lot!
I edited utils.py Then download with command |
Thanks this has worked for me |
this help me.. thanks ... |
🚨Please review the Troubleshooting section
before reporting any issue. Don't forget to check also the current issues to
avoid duplicates.
AttributeError
Receiving the following error:
AttributeError: 'HTMLParser' object has no attribute 'unescape'
Your environment
Steps to reproduce
Method:
file
requirements.txt
.your username and password, but leave all other information untouched).
--debug
option before posting the messages as a bug report. Please, copy and paste
them. Don't reword/paraphrase the messages.
Expected behaviour
Tell us what should happen.
Actual behaviour
C:\Users\ryan1\Documents>coursera-dl regression-models
coursera_dl version 0.11.5
Downloading class: regression-models (1 / 1)
Parsing syllabus of on-demand course . This may take some time, please be patient ...
Processing module week-1-least-squares-and-linear-regression
Processing section introduction
Processing lecture welcome-to-regression-models (supplement)
Traceback (most recent call last):
File "c:\users\ryan1\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\ryan1\appdata\local\programs\python\python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\ryan1\AppData\Local\Programs\Python\Python39\Scripts\coursera-dl.exe_main.py", line 7, in
File "c:\users\ryan1\appdata\local\programs\python\python39\lib\site-packages\coursera\coursera_dl.py", line 247, in main
error_occurred, completed = download_class(
File "c:\users\ryan1\appdata\local\programs\python\python39\lib\site-packages\coursera\coursera_dl.py", line 214, in download_class
return download_on_demand_class(session, args, class_name)
File "c:\users\ryan1\appdata\local\programs\python\python39\lib\site-packages\coursera\coursera_dl.py", line 134, in download_on_demand_class
error_occurred, modules = extractor.get_modules(
File "c:\users\ryan1\appdata\local\programs\python\python39\lib\site-packages\coursera\extractors.py", line 53, in get_modules
error_occurred, modules = self._parse_on_demand_syllabus(
File "c:\users\ryan1\appdata\local\programs\python\python39\lib\site-packages\coursera\extractors.py", line 161, in _parse_on_demand_syllabus
links = course.extract_links_from_supplement(
File "c:\users\ryan1\appdata\local\programs\python\python39\lib\site-packages\coursera\api.py", line 1268, in extract_links_from_supplement
supplement_content, self._extract_links_from_text(value))
File "c:\users\ryan1\appdata\local\programs\python\python39\lib\site-packages\coursera\api.py", line 1518, in _extract_links_from_text
supplement_links = self._extract_links_from_a_tags_in_text(text)
File "c:\users\ryan1\appdata\local\programs\python\python39\lib\site-packages\coursera\api.py", line 1597, in _extract_links_from_a_tags_in_text
extension = clean_filename(
File "c:\users\ryan1\appdata\local\programs\python\python39\lib\site-packages\coursera\utils.py", line 118, in clean_filename
s = h.unescape(s)
AttributeError: 'HTMLParser' object has no attribute 'unescape'
The text was updated successfully, but these errors were encountered: