问题描述
我正在尝试使用 cx_freeze
为使用 aiohttp $ c $用Python 3编写的Web应用程序构建一个二进制dist。 c>包。
I'm trying to use cx_freeze
to build a binary dist for an web application written in Python 3 using the aiohttp
package.
我基本上做到了:
cxfreeze server.py
并获得 dist
的输出
但是运行 ./ server
二进制文件时,出现以下消息:
But when running the ./server
binary, I got the following message:
File "/usr/local/lib/python3.5/dist-packages/cx_Freeze/initscripts/__startup__.py", line 12, in <module>
__import__(name + "__init__")
File "/usr/local/lib/python3.5/dist-packages/cx_Freeze/initscripts/Console.py", line 24, in <module>
exec(code, m.__dict__)
File "server.py", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/aiohttp/__init__.py", line 10, in <module>
from .protocol import * # noqa
File "/usr/local/lib/python3.5/dist-packages/aiohttp/protocol.py", line 17, in <module>
from . import errors, hdrs
File "/usr/local/lib/python3.5/dist-packages/aiohttp/errors.py", line 3, in <module>
from asyncio import TimeoutError
File "/usr/lib/python3.5/asyncio/__init__.py", line 21, in <module>
from .base_events import *
File "/usr/lib/python3.5/asyncio/base_events.py", line 32, in <module>
from . import compat
ImportError: cannot import name 'compat'
推荐答案
希望您已经能够解决此问题,但是对于像我一样搜索此问题的人,我会回答:
Hopefully you've been able to fix this already, but for people searching this question like I was, I'll answer:
此 compat
模块是 asyncio
的一部分,并且未被cx_Freeze发现。我必须将 asyncio
添加到 build_exe
packages 列表中> setup.py
中的选项将其包括在内:
This compat
module is part of asyncio
, and not getting discovered by cx_Freeze. I had to add asyncio
to the packages
list in the build_exe
options in setup.py
to get it to be included:
setup(
...
options = {
'build_exe': {
'packages': ['encodings', 'asyncio']
},
}
)
这篇关于cxfreeze aiohttp无法导入compat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!