cxfreeze aiohttp cannot import compat

2024/10/8 19:40:18

I'm trying to use cx_freeze to build a binary dist for an web application written in Python 3 using the aiohttp package.

Basically I did:

cxfreeze server.py

and got a dist output

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 *  # noqaFile "/usr/local/lib/python3.5/dist-packages/aiohttp/protocol.py", line 17, in <module>from . import errors, hdrsFile "/usr/local/lib/python3.5/dist-packages/aiohttp/errors.py", line 3, in <module>from asyncio import TimeoutErrorFile "/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 compatImportError: cannot import name 'compat'
Answer

Hopefully you've been able to fix this already, but for people searching this question like I was, I'll answer:

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']},}
)
https://en.xdnf.cn/q/70104.html

Related Q&A

Python open() requires full path [duplicate]

This question already has answers here:open() gives FileNotFoundError / IOError: [Errno 2] No such file or directory(11 answers)Closed 9 months ago.I am writing a script to read a csv file. The csv fil…

Pandas to parquet file

I am trying to save a pandas object to parquet with the following code: LABL = datetime.now().strftime("%Y%m%d_%H%M%S") df.to_parquet("/data/TargetData_Raw_{}.parquet".format(LABL))…

Wildcard in dictionary key

Suppose I have a dictionary:rank_dict = {V*: 1, A*: 2, V: 3,A: 4}As you can see, I have added a * to the end of one V. Whereas a 3 may be the value for just V, I want another key for V1, V2, V2234432, …

How to read emails from gmail?

I am trying to connect my gmail to python, but show me this error: I already checked my password, any idea what can be? b[AUTHENTICATIONFAILED] Invalid credentials (Failure) Traceback (most recent cal…

Python multiprocessing returning AttributeError when following documentation code [duplicate]

This question already has answers here:python multiprocessing in Jupyter on Windows: AttributeError: Cant get attribute "abc"(4 answers)Closed 4 years ago.I decided to try and get into the mu…

Python - How can I find if an item exists in multidimensional array?

Ive tried a few approaches, none of which seem to work for me. board = [[0,0,0,0],[0,0,0,0]]if not 0 in board:# the board is "full"I then tried:if not 0 in board[0] or not 0 in board[1]:# the…

Convert Geo json with nested lists to pandas dataframe

Ive a massive geo json in this form:{features: [{properties: {MARKET: Albany,geometry: {coordinates: [[[-74.264948, 42.419877, 0],[-74.262041, 42.425856, 0],[-74.261175, 42.427631, 0],[-74.260384, 42.4…

Pymongo - ValueError: NaTType does not support utcoffset when using insert_many

I am trying to incrementally copy documents from one database to another. Some fields contain date time values in the following format:2016-09-22 00:00:00while others are in this format:2016-09-27 09:0…

python numpy argmax to max in multidimensional array

I have the following code:import numpy as np sample = np.random.random((10,10,3)) argmax_indices = np.argmax(sample, axis=2)i.e. I take the argmax along axis=2 and it gives me a (10,10) matrix. Now, I …

Can Keras model.predict return a dictionary?

The documentation https://keras.io/models/model/#predict says that model.predict returns Numpy array(s) of predictions. In the Keras API, is there is a way to distinguishing which of these arrays are…