mirror of
https://github.com/sigma67/ytmusicapi.git
synced 2026-04-25 07:16:00 +03:00
[GH-ISSUE #250] File "ytmusicapi\ytmusic.py", line 102, in __init__ not found #193
Labels
No labels
a/b
bug
documentation
enhancement
good first issue
help wanted
invalid
pull-request
question
wontfix
yt-error
yt-update
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ytmusicapi#193
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SpikyPhrog on GitHub (Jan 3, 2022).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/250
HI, I've used your wonderful api to create a player. The api works absolutely flawlessly, however when I tried to create an executable using pyinstaller and upon completion of the pyinstaller, when I run the exe file I get the following message:
`
Failed to execute script 'main' due to unhandled exception: [WinError3] The system cannot find the path specified: 'C:\Users\User\AppData\Local\Temp\_MEI39042\ytmusicapi\locales'
Traceback (most recent call last):
File "main.py", line 10, in
File "ytmusicapi\ytmusic.py", line 102, in init
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\Users\User\AppData\Local\Temp\_MEI39042\ytmusicapi\locales'
`
Any ideas on why would that happen or where can I get the installed files? Thanks a lot in advance!
@sigma67 commented on GitHub (Jan 4, 2022):
I've never used pyinstaller, but I think you need to tell it to also include the package data of the dependency. ytmusicapi can't find the
localesdirectory needed for localization, which it expects to be in the path specified in your error.Perhaps this is also related to #223, you may try using resource_listdir like here in your fork of ytmusicapi
@SpikyPhrog commented on GitHub (Jan 4, 2022):
Thank you for the swift reply pal! I am afraid that unfortunatelly it did not quite work as it raised another issue now, this time about the supported languages. What I did with the solution that you suggested was to swap the original code to this one
supported_languages = [f for f in pkg_resources.resource_listdir('ytmusicapi', 'locales')] #locale_dir = os.path.abspath(os.path.dirname(__file__)) + os.sep + 'locales' #supported_languages = [f for f in os.listdir(locale_dir)] if language not in supported_languages: raise Exception("Language not supported. Supported languages are " ', '.join(supported_languages)) self.language = language try: locale.setlocale(locale.LC_ALL, self.language) except locale.Error: with suppress(locale.Error): locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') self.lang = gettext.translation('base', **localedir=pkg_resources.resource_filename( 'ytmusicapi', 'locales'),** languages=[language]) self.parser = browsing.Parser(self.lang)and of course imported the pkg_resources.. Now when I run it through the pyinstaller, once its done it yells the following error:
Traceback (most recent call last): File "main.py", line 10, in <module> YTMusic = YTMusic() File "ytmusicapi\ytmusic.py", line 106, in __init__ Exceptionwhich line 10 is
from ytmusicapi.setup import setupand 106 is
raise Exception("Language not supported. Supported languages are "I thank you ever so much for taking the time and I appreciate the effort to help pal! If there is no solution to it I will try to find another way to make it run not from the editor. Again, many thanks!
I did the screenshot purely because the formating in the preview looked awful. The red underlining are the things I've changed.
@sigma67 commented on GitHub (Jan 5, 2022):
I believe this is related: https://stackoverflow.com/questions/46474588/pyinstaller-how-to-include-data-files-from-an-external-package-that-was-install
@glomatico commented on GitHub (Feb 15, 2022):
I'm having this same issue. Any fix?
@rickyrorton commented on GitHub (Jun 11, 2022):
I use auto-py-to-exe (gui for pyinstaller) and adding ytmusicapi under collect-all option worked for

and if you use from command line i think you just have to mention the following in the arguments
--collect-all "ytmusicapi"