Closed nicolapreda closed 3 years ago
Your file is named ytm.py
which Python will recognise as a module named ytm
, which is also the name of the module you're trying to import. To resolve this issue, rename your ytm.py
file to something else (e.g. app.py
)
Your file is named
ytm.py
which Python will recognise as a module namedytm
, which is also the name of the module you're trying to import. To resolve this issue, rename yourytm.py
file to something else (e.g.app.py
)
If I rename the file, it gives me this error:
In app.py
you use the line:
ytm = ytm.YouTubeMusic()
This will overwrite the reference to the ytm
module, which is then used again in the line:
return song_url(ytm.YouTubeMusic().search_songs(query)['items'][0]['id'])
To fix this, your code should look something like this:
import ytm
youtubemusic = ytm.YouTubeMusic()
def song_url(song_id: str) -> str:
return ytm.utils.url_ytm('watch', params = {'v': song_id})
def search(query: str) -> str:
return song_url(youtubemusic.search_songs(query)['items'][0]['id'])
print(search('liztomania'))
Hope this helps!
Thank you very much!! I didn't think the name of the variable would give problems ... XD
I tryed to insert this code and run it, but, after the installation of the package, python doesn't find it. How can I resolve this error?