我正在尝试使用cx_freeze
为使用aiohttp
包在Python 3中编写的Web应用程序构建二进制dist。
基本上我做了:
cxfreeze server.py
并获得dist
输出
但是当运行./server
二进制文件时,我收到以下消息:
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'
答案 0 :(得分:15)
希望你已经能够解决这个问题了,但对于像我一样搜索这个问题的人,我会回答:
此compat
模块是asyncio
的一部分,并且未被cx_Freeze发现。我必须将asyncio
添加到packages
build_exe
选项中的setup.py
列表中,以便将其包括在内:
setup(
...
options = {
'build_exe': {
'packages': ['encodings', 'asyncio']
},
}
)