python - pyinstaller "RuntimeWarning: Parent module 'PyInstaller.hooks.hook-PIL' not found while handling absolute import" 和 "tcl" 相关错误
python - pyinstaller "RuntimeWarning: Parent module 'PyInstaller.hooks.hook-PIL' not found while handling absolute import" and "tcl" related errors
我在尝试使用 pyinstaller
创建可执行文件时收到一条警告消息。安装 Pillow
后出现此警告。以前我从来没有收到任何警告并且能够通过。
我从 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 *
此外,当我尝试 运行 可执行文件的 exe/consol 版本的代码位于由 pyinstaller (dist/main/main
) 创建的 dist 文件夹中时,会显示这些内容..
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
。即使那样也没有帮助。
我也试过重新安装 pyinstaller
。也没有帮助
更新 1:
Pyinstaller/hooks
目录中似乎缺少 Pyinstaller.hooks.hook-PIL.py
文件。它在所有平台上都缺失(Mac、windows 和 linux)。这是我在 windows 上收到的 warning/error 消息,这与我在 mac 和 linux. 上收到的消息相同
后来我发现了一个link,上面写着,它是just to need Python import machinery happy
。所以我这么说创建。然后我在所有平台上都没有得到相同的错误,但是在 mac 上我仍然得到 PILImagePlugin
、Image
和 FixTk
错误
tcl
的解决方案:
我发现出了什么问题,.. 我在 OSX
上遇到的每个问题都是 OS
本身(正是 macport
)。 Python默认自带macOS。而这个版本的 python 可能对学习基础 python 有用,但不适合开发目的。
安装 brew 的 python 有帮助。我关注了这个。完成这些之后,我仍然遇到错误。后来我不得不更改 /etc/paths
上的路径。基本上重新排列它们应该有效。但是那时我还是没有做对。
然后我不得不更改 .bash_profile
,它适用于大多数用户,但我仍然得到 mac 版本的 python 和 pip,而不是 brews 版本python。
最后我不得不重新启动 machine 几次并重复执行 /etc/paths
和 .bash_profile
步骤以获得系统范围的效果以接受 brews 版本的 python 和 pip
PIL
的解决方案:
只需添加一个名为 hook-PIL.py
且内容为空的文件即可达到目的。我找到了一个 link,它的挂钩文件内容为 pyinstaller
。
创建位置
for mac : /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/hooks/
其实对于 mac 这一步不会必需的。当我们通过 brew 安装 python 并更改路径时,您稍后尝试通过 pip install
或从 source packages
安装的所有内容往往会选择不同的路径。一切都会得到照顾。
对于 windows:C:\Python27\lib\site-packages\PyInstaller-2.1.1.dev0-py2.7.egg\PyInstaller\hooks
**请在创建文件之前检查这是否是您 machine 上的有效路径,然后再创建文件。我不确定或者我不知道只添加一个空文件是否是正确的方法。但它对我有用
我在尝试使用 pyinstaller
创建可执行文件时收到一条警告消息。安装 Pillow
后出现此警告。以前我从来没有收到任何警告并且能够通过。
我从 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 *
此外,当我尝试 运行 可执行文件的 exe/consol 版本的代码位于由 pyinstaller (dist/main/main
) 创建的 dist 文件夹中时,会显示这些内容..
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
。即使那样也没有帮助。
我也试过重新安装 pyinstaller
。也没有帮助
更新 1:
Pyinstaller/hooks
目录中似乎缺少 Pyinstaller.hooks.hook-PIL.py
文件。它在所有平台上都缺失(Mac、windows 和 linux)。这是我在 windows 上收到的 warning/error 消息,这与我在 mac 和 linux.just to need Python import machinery happy
。所以我这么说创建。然后我在所有平台上都没有得到相同的错误,但是在 mac 上我仍然得到 PILImagePlugin
、Image
和 FixTk
错误
tcl
的解决方案:
我发现出了什么问题,.. 我在 OSX
上遇到的每个问题都是 OS
本身(正是 macport
)。 Python默认自带macOS。而这个版本的 python 可能对学习基础 python 有用,但不适合开发目的。
安装 brew 的 python 有帮助。我关注了这个/etc/paths
上的路径。基本上重新排列它们应该有效。但是那时我还是没有做对。
然后我不得不更改 .bash_profile
,它适用于大多数用户,但我仍然得到 mac 版本的 python 和 pip,而不是 brews 版本python。
最后我不得不重新启动 machine 几次并重复执行 /etc/paths
和 .bash_profile
步骤以获得系统范围的效果以接受 brews 版本的 python 和 pip
PIL
的解决方案:
只需添加一个名为 hook-PIL.py
且内容为空的文件即可达到目的。我找到了一个 link,它的挂钩文件内容为 pyinstaller
。
创建位置
for mac : 其实对于 mac 这一步不会必需的。当我们通过 brew 安装 python 并更改路径时,您稍后尝试通过 /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/hooks/
pip install
或从 source packages
安装的所有内容往往会选择不同的路径。一切都会得到照顾。
对于 windows:C:\Python27\lib\site-packages\PyInstaller-2.1.1.dev0-py2.7.egg\PyInstaller\hooks
**请在创建文件之前检查这是否是您 machine 上的有效路径,然后再创建文件。我不确定或者我不知道只添加一个空文件是否是正确的方法。但它对我有用