Python - pyinstaller "RuntimeWarning: parent module" PyInstaller.hooks.hook-PIL "was not detected while processing absolute import" and "tcl" related errors

I get a warning when trying to create an exectable file using pyinstaller . This warning appeared after installing Pillow . I used to get any warnings from a neur and was able to do this.

warning i get with pyinstaller:

 7314 INFO: Analyzing main.py /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/hooks/hook-PIL.Image.py:14: RuntimeWarning: Parent module 'PyInstaller.hooks.hook-PIL' not found while handling absolute import from PyInstaller.hooks.shared_PIL_Image import * 

Also, when I tried to run the exe / consol executable version of my code, which is inside the dist folder created by pyinstaller ( dist/main/main ), they are displayed.

 Traceback (most recent call last): File "<string>", line 26, in <module> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 276, in load_module exec(bytecode, module.__dict__) File "/Users/..../build/main/out00-PYZ.pyz/PIL.PngImagePlugin", line 40, in <module> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 276, in load_module exec(bytecode, module.__dict__) File "/Users/..../build/main/out00-PYZ.pyz/PIL.Image", line 53, in <module> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 276, in load_module exec(bytecode, module.__dict__) File "/Users/..../build/main/out00-PYZ.pyz/FixTk", line 74, in <module> OSError: [Errno 20] Not a directory: '/Users/.../dist/main/tcl' logout [Process completed] 

so I tried uninstalling Pillow by installing the tk tcl dev version. And then install Pillow . Even that didn't help.

I also tried reinstalling pyinstaller . didn't help either

Update 1:

It seems the Pyinstaller.hooks.hook-PIL.py file Pyinstaller.hooks.hook-PIL.py not in the Pyinstaller/hooks directory. And it was absent on all platforms (Mac, windows and linux). This is a warning / error message that I get on windows that I received on Mac and on Linux. windows error / warning Later I found a link that said its just to need Python import machinery happy . therefore, I created as I said so. Then I do not get the same error on all platforms, but on mac I still get PILImagePlugin , Image and FixTk

0
source share
1 answer

Solution for tcl :

I realized what was going wrong. Every problem I encountered on OSX was the OS itself (exactly macport ). Python comes with Mac OS by default. And this version of python may be useful for simple learning basic python, but not suitable for development purposes.

Install brew python. I followed this SO link . After that, I was still getting errors. Later I had to change the paths to /etc/paths . Basically, their restructuring should work. But still I did not understand.

Then I had to change the .bash_profile , which worked for most users. But still, I was getting the mac version of python and pip, not the python version for brewers.

Finally, I had to restart the machine a couple of times and execute the /etc/paths and .bash_profile steps several times to get the effect of the whole system in order to accept the python and pip beer version


Solution for PIL :

just a file called hook-PIL.py with empty content will be added. I found a link that contained the contents of the hook files in pyinstaller .

Location to create

for mac: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/hooks/ Actually for mac this step is not required. When we install python through brew and change the path, everything that you try to install later, either through pip install or from source packages , tends to choose a different path. And everything will be taken care of.

for windows: C:\Python27\lib\site-packages\PyInstaller-2.1.1.dev0-py2.7.egg\PyInstaller\hooks

** Please check if this is a valid path on your computer before creating the file, and then create the file. And I'm not sure, or I don't know if the empty file was added correctly. But it worked for me.

+1
source

Source: https://habr.com/ru/post/977316/


All Articles