Hey,
kennt sich da jemand aus:
https://github.com/trash/khinsider-mp3-downloader
Fehler: SyntaxError: invalid syntax
thx
Druckbare Version
Hey,
kennt sich da jemand aus:
https://github.com/trash/khinsider-mp3-downloader
Fehler: SyntaxError: invalid syntax
thx
da scheint was mit deiner lokalen python Umgebung nicht korrekt zu sein.
Wie führst du das script denn aus?
Mit `python3 downloader.py` funktioniert das bei mir unter Python 3.9.10 ohne Probleme. Mehr ist da eigentlich nicht nötig.
Vermutlich startest du das script mit `./downloader.py`, da im Script aber kein Shebang angegeben ist schlägt das fehl (bei mir auch).
Entweder du startest das Script dann explizit mit `python3` oder du fügst folgende Shebang in die erste Zeile des Scripts ein: `#!/usr/bin/env python3`.
Wenn das ebenfalls nicht funktioniert ist wie erwähnt was mit deiner lokalen Python Umgebung nicht korrekt. Was zeigt dir `which python` oder `type -a python` an?
das ist das erste mal, dass ich dies verwende.
Kenn mich da überhaupt nicht aus.
Ich muss mit "IDLE (Python 3.10 64-bit)"
das script starten oder?
File-Open-downloader.py-Run
da kommt: from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'
edit: habs hinbekommen ;)
- - - - - - - - - - Beitrag nachträglich erweitert - - - - - - - - - -
Was ich derzeit bekomme:
OSError: [WinError 123] Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch:
Kann man das irgendwie beheben?
versuch mal in downloader.py Zeile 76
file_on_disk_path = dir_name + '/' + file_name
... durch ....
file_on_disk_path = dir_name + '\\' + file_name
.... zu ersetzen
Traceback (most recent call last):
File "F:\- Musik ( Soundtrack - Movies-Series-Games )\- unbearbeitet\- Khinsider\- - - Script\khinsider-mp3-downloader-master\downloader.py", line 98, in <module>
fetch_from_url(line)
File "F:\- Musik ( Soundtrack - Movies-Series-Games )\- unbearbeitet\- Khinsider\- - - Script\khinsider-mp3-downloader-master\downloader.py", line 30, in fetch_from_url
os.makedirs(dir_name)
File "C:\Users\Asus\AppData\Local\Programs\Python\Pytho n310\lib\os.py", line 225, in makedirs
mkdir(name, mode)
OSError: [WinError 123] Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch: 'downloads/o-chan-no-oekaki-logic-1995-saturn-gamerip\n'
Gern den Traceback immer gleich mitliefern, dann hätte readabook nicht falsch geraten, wo man ansetzen muss.
Neuer Versuch:
Code:downloader.py
Ersetze Zeile 96:
file = open(input_file_name, 'r')
mit
file = open(input_file_name, 'r').read().splitlines()
Er startet nun, es kommt aber trotzdem noch folgendes:
Warning (from warnings module):
File "F:\- Musik ( Soundtrack - Movies-Series-Games )\- unbearbeitet\- Khinsider\- - - Script\khinsider-mp3-downloader-master\downloader.py", line 34
soup = BeautifulSoup(urllib2.urlopen(url))
GuessedAtParserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("html.parser"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.
The code that caused this warning is on line 34 of the file F:\- Musik ( Soundtrack - Movies-Series-Games )\- unbearbeitet\- Khinsider\- - - Script\khinsider-mp3-downloader-master\downloader.py. To get rid of this warning, pass the additional argument 'features="html.parser"' to the BeautifulSoup constructor.
[info] 13 links acquired
Warning (from warnings module):
File "F:\- Musik ( Soundtrack - Movies-Series-Games )\- unbearbeitet\- Khinsider\- - - Script\khinsider-mp3-downloader-master\downloader.py", line 62
link_soup = BeautifulSoup(urllib2.urlopen(href))
GuessedAtParserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("html.parser"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.
The code that caused this warning is on line 62 of the file F:\- Musik ( Soundtrack - Movies-Series-Games )\- unbearbeitet\- Khinsider\- - - Script\khinsider-mp3-downloader-master\downloader.py. To get rid of this warning, pass the additional argument 'features="html.parser"' to the BeautifulSoup constructor.
Die Meldung solltest du ignorieren können.
Du kannst es aber dennoch korrigieren:
34 soup = BeautifulSoup(urllib2.urlopen(url)) -> soup = BeautifulSoup(urllib2.urlopen(url), 'html.parser')
62 link_soup = BeautifulSoup(urllib2.urlopen(href)) -> link_soup = BeautifulSoup(urllib2.urlopen(href), 'html.parser')
Optimalerweise antwortest du noch auf die "Issues" bei Github mit den entsprechenden Lösungen aus diesem Thread.
funktioniert nun ;)
danke