Closed BobAchgill closed 7 years ago
Hi Bob, I think there is a problem in packaging the module, maybe it needs specific changes to be compatible with PyInstaller, I'll take a look and update the ticket
Thank you! Bob
From: Abdullah Diab notifications@github.com Sent: Saturday, June 10, 2017 7:20:09 PM To: mpcabd/python-arabic-reshaper Cc: BobAchgill; Author Subject: Re: [mpcabd/python-arabic-reshaper] PyInstaller and Python-arabic-reshaper (Python 2.7) (#12)
Hi Bob, I think there is a problem in packaging the module, maybe it needs specific changes to be compatible with PyInstaller, I'll take a look and update the ticket
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/mpcabd/python-arabic-reshaper/issues/12#issuecomment-307597838, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AYPwlM6UtzNMwfzWjU89MC7EPWgbvbM1ks5sCzK5gaJpZM4NhGfp.
Hi @BobAchgill,
The problem is that PyInstaller is not packaging the data files of the module when it's creating the PYZ, for some very weird reason, I couldn't really find what's going on on their end, but I managed to make it work by editing the spec file like this:
import pkg_resources
...
a = Analysis(
...
datas=[
...,
(
pkg_resources.resource_filename('arabic_reshaper', 'default-config.ini'),
'arabic_reshaper'
),
...
],
...
)
...
This will make PyInstaller package the configuration file for this module along, it might be worth checking with PyInstaller team on what's going on, and how to solve this, because I saw that in their docs they have something similar for matplotlib data for example.
I couldn't find anything that I can do to my package to make PyInstaller pick that file up, so I'm closing the issue as well, hope this helps you, please let me know if you hear from them.
Hi @BobAchgill,
The problem is that PyInstaller is not packaging the data files of the module when it's creating the PYZ, for some very weird reason, I couldn't really find what's going on on their end, but I managed to make it work by editing the spec file like this:
import pkg_resources ... a = Analysis( ... datas=[ ..., ( pkg_resources.resource_filename('arabic_reshaper', 'default-config.ini'), 'arabic_reshaper' ), ... ], ... ) ...
This will make PyInstaller package the configuration file for this module along, it might be worth checking with PyInstaller team on what's going on, and how to solve this, because I saw that in their docs they have something similar for matplotlib data for example.
I couldn't find anything that I can do to my package to make PyInstaller pick that file up, so I'm closing the issue as well, hope this helps you, please let me know if you hear from them.
I did the same but it did not work for me. Any suggestion. Thanks
@hsielecpart just copy and paste Arabic reshaper folder next to your code or generated executable file, that will resolve the issue
@hsielecpart just copy and paste Arabic reshaper folder next to your code or generated executable file, that will resolve the issue
I did but still not working. Seems like pyinstaller is not finding the config file. This is the error i got. I know i have to edit or make pyinstaller know current directory(because i put the config file in the same directory)
@hsielecpart you just did opposite of what I told you, remove it from pip and python or anaconda folder, and put Arabic reshaper in the folder next to the file you are coding, and when you make an exe try to copy Arabic reshaper next to created exe
@hsielecpart you just did opposite of what I told you, remove it from pip and python or anaconda folder, and put Arabic reshaper in the folder next to the file you are coding, and when you make an exe try to copy Arabic reshaper next to created exe
Thanks for your help. This is what i did after putting arabic_reshaper in my code directory I edited the arabic_reshaper and it's init file .
1-In arabic_reshaper added this line configuration_files=['your code path\arabic_reshaper\default-config.ini']
put this line after these lines to rewrite configuration_files
configuration_files = [
resource_filename(application_path, 'default-config.ini')
]
2-And in init.py in arabic_reshaper folder edited this line:
exec(open(os.path.join(os.path.dirname('your code path\arabic_reshaper\init.p'), 'version.py')).read())
It will automatically consider your config file in arabic_reshaper folder that you put inside your code
I am trying to use PyInstaller to put an exe wrapper around my code that imports Python-arabic-reshaper, but I got this error,
Traceback (most recent call last): File "<string>", line 20, in <module> File "C:\Users\Ownerc\Downloads\PyInstaller-2.1\PyInstaller-2.1\PyInstaller\lo ader\pyi_importers.py", line 270, in load_module File "C:\Python27\build\hhr_video_maker - Copy\out00-PYZ.pyz\arabic_reshaper", line 1, in <module> File "C:\Users\Ownerc\Downloads\PyInstaller-2.1\PyInstaller-2.1\PyInstaller\lo ader\pyi_importers.py", line 270, in load_module File "C:\Python27\build\hhr_video_maker - Copy\out00-PYZ.pyz\arabic_reshaper.a rabic_reshaper", line 1377, in <module> File "C:\Python27\build\hhr_video_maker - Copy\out00-PYZ.pyz\arabic_reshaper.a rabic_reshaper", line 1248, in __init__ ValueError: Invalid configuration: A section with the name ArabicReshaper was no t found
The config file I was using is default-config.ini, I have also had configparser package installed.
Thank you,
Just an update... We made a very simple Python 2.7 script that uses the Python-arabic-reshaper library. The script runs successfully but fails when packaged into an exe using Pyinstaller.
The Pyinstaller (tool that packages the Python script and libraries into an exe) documentation says suggests to use the archive viewer to see what library files may have been missed in being included in the exe package.
Below is the archive viewer output that shows all the assets included in the pyinstaller "exe" package. Can you identify any missing files from the exe package that the Python-arabic-reshaper needs in order to run?
Here is the simple Python script that I used to test...