Hi Julie, Looking at the source for anyascii, it uses importlib.resources to grab those binaries, so I think it should be able to just grab them as you're trying to do (if it anyascii were just doing "open...read", that would probably result in some different strategy being needed).
In any case, when you run your pyinstaller command, have you noted that it produces a file "xxx.spec" (xxx is your exe name)? To make this easier (easiest?), start using that file instead of jamming a bunch of stuff on the command line. First, make sure you have a good spec, assuming your old command line looked like: $ pyinstaller xxx.py --a-bunch-of-stuff you'll now use this in its place: $ pyinstaller xxx.spec as "xxx.spec" contains all the settings from the command line. Edit that file and look for "hiddenimports" in the "Analysis" block, I think that is the most likely candidate to solve this. Change it to something like hiddenimports = ['anyascii._data.000', 'anyascii._data.001'], and try the build, see if it coughs up any errors or reports that yes indeed it's including those data files. I'm sort of educated-guessing on the names listed there, but it should be something very close to that. If it works, then write some code in the .spec file that looks grossly like (yes, the is hacky, but it should give you the idea): from glob import glob from os.path import split includes = [] for data_file in glob('wherever/they/live/anyascii/_data/*'): dir, name = split(data_file) if len(name) == 3: # <-- The super hacky part... includes.append('anyascii._data.%s' % name) then change that hiddenimports to hiddenimports = includes, Run "pyinstaller xxx.spec" and see if it works. Eric On Wed, Mar 1, 2023 at 12:02 AM Julie N <julie.nelson....@gmail.com> wrote: > Hi all, > > I have a fairly simple script that uses anyascii ( > https://pypi.org/project/anyascii/) and works fine when run in a > development environment. > > However, when built into an executable with PyInstaller, I start seeing > problems. > > First, an exception was thrown saying the module 'anyascii._data' couldn't > be found. Looking in the installation, there is a subfolder of this name > which appears to hold the datafiles used to do the Unicode to ascii > transliteration. > > Adding > > from anyascii import _data > > to my script got rid of the exception, but anyascii still doesn't work -- > it replaces the Unicode characters with nothing instead of the desired > substitutions, that is, it still can't seem to find its datafiles! > > So I have tried to add lots of variations of the following to my command > line: > > --add-data "[path to Python > installation]\Python\Python37\Lib\site-packages\anyascii\_data\*;anyascii._data" > > ...but still no luck! Any advice about how to incorporate these datafiles > so anyascii can find them? > > Googling, of course, has yielded nothing. :( I'm also building with > --debug=imports, but the output hasn't yielded anything helpful either. > > Any advice about how to correctly incorporate these datafiles into my > executable? > > Thanks! > > Julie > > -- > You received this message because you are subscribed to the Google Groups > "PyInstaller" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pyinstaller+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/pyinstaller/361386f0-c39d-47e6-8374-1cfaac6e0a7en%40googlegroups.com > <https://groups.google.com/d/msgid/pyinstaller/361386f0-c39d-47e6-8374-1cfaac6e0a7en%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "PyInstaller" group. To unsubscribe from this group and stop receiving emails from it, send an email to pyinstaller+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/CAP2Qz%2BXvU4%3DDzQxUkNXsbfuws7T%2BQE6xsKqGO8aKv9X-7hZZLw%40mail.gmail.com.