本文介绍了python-pyinstaller“运行时警告:在处理绝对导入时找不到父模块'PyInstaller.hooks.hook-PIL'"和"tcl"相关错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用pyinstaller创建可执行文件时收到警告消息.安装Pillow后出现此警告.以前,我nevre收到了任何警告,并且能够通过.

I get a warning message while trying to create exectable file using pyinstaller. This warning appeared after installing Pillow. Previously i nevre got any warnings and was able to make it through.

我通过pyinstaller收到的警告是:

the warning i get by pyinstaller is:

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 *

此外,当我尝试运行由pyinstaller(dist/main/main)创建的dist文件夹中的代码的可执行文件的exe/consol版本时,也会显示这些..

Also when i tried to run the executable's exe/consol version of my code that lies inside the dist folder created by the pyinstaller (dist/main/main), these 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]

因此,我尝试通过卸载pillow,安装tk tcl dev版本进行操作.然后安装pillow.即使那样也没有帮助.

so, i tried by uninstalling pillow, installing tk tcl dev version. And then installed pillow. Even that didnt helped.

我也尝试重新安装pyinstaller.也没有帮助

I also tried reinstalling pyinstaller,. didnt help too

对于Mac,实际上不需要此步骤.当我们通过brew安装python并更改路径时,您以后尝试通过pip install或从source packages安装的所有内容都倾向于选择不同的路径.一切都会得到照顾.

Actually for mac this step wouldn’t be 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 tend to choose a different path. And everything will be taken care of.

对于Windows: C:\Python27\lib\site-packages\PyInstaller-2.1.1.dev0-py2.7.egg\PyInstaller\hooks

****在创建文件然后创建文件之前,请检查这是您计算机上的有效路径.我不确定还是我不知道是否只是添加一个空文件是正确的方法.但这对我有用

这篇关于python-pyinstaller“运行时警告:在处理绝对导入时找不到父模块'PyInstaller.hooks.hook-PIL'"和"tcl"相关错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 16:46