Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module 'collections' has no attribute 'Iterable' error on Python 3.10.6 #2

Open
xylophone21 opened this issue Aug 14, 2022 · 1 comment

Comments

@xylophone21
Copy link

https://stackoverflow.com/questions/53978542/how-to-use-collections-abc-from-both-python-3-8-and-python-2-7/

Exception has occurred: AttributeError
module 'collections' has no attribute 'Iterable'
File "C:\Users\xxx\Documents\minecraft\code\mcpi_e\util.py", line 5, in flatten
if isinstance(e, collections.Iterable) and not isinstance(e, str):
File "C:\Users\xxx\Documents\minecraft\code\mcpi_e\util.py", line 10, in flatten_parameters_to_bytestring
return b",".join(map(_misc_to_bytes, flatten(l)))
File "C:\Users\xxx\Documents\minecraft\code\mcpi_e\connection.py", line 76, in send
s = b"".join([f, b"(", flatten_parameters_to_bytestring(data), b")", b"\n"])
File "C:\Users\xxx\Documents\minecraft\code\mcpi_e\connection.py", line 101, in sendReceive
self.send(*data)
File "C:\Users\xxx\Documents\minecraft\code\mcpi_e\minecraft.py", line 399, in create
playerId= int(conn.sendReceive(b"world.getPlayerId", playerName))
File "C:\Users\xxx\Documents\minecraft\code\test.py", line 9, in
mc = Minecraft.create(serverAddress,pythonApiPort,playerName)

@ph-fox
Copy link

ph-fox commented Apr 5, 2023

https://stackoverflow.com/questions/53978542/how-to-use-collections-abc-from-both-python-3-8-and-python-2-7/

Exception has occurred: AttributeError module 'collections' has no attribute 'Iterable' File "C:\Users\xxx\Documents\minecraft\code\mcpi_e\util.py", line 5, in flatten if isinstance(e, collections.Iterable) and not isinstance(e, str): File "C:\Users\xxx\Documents\minecraft\code\mcpi_e\util.py", line 10, in flatten_parameters_to_bytestring return b",".join(map(_misc_to_bytes, flatten(l))) File "C:\Users\xxx\Documents\minecraft\code\mcpi_e\connection.py", line 76, in send s = b"".join([f, b"(", flatten_parameters_to_bytestring(data), b")", b"\n"]) File "C:\Users\xxx\Documents\minecraft\code\mcpi_e\connection.py", line 101, in sendReceive self.send(*data) File "C:\Users\xxx\Documents\minecraft\code\mcpi_e\minecraft.py", line 399, in create playerId= int(conn.sendReceive(b"world.getPlayerId", playerName)) File "C:\Users\xxx\Documents\minecraft\code\test.py", line 9, in mc = Minecraft.create(serverAddress,pythonApiPort,playerName)

open the util.py file: C:\Users\xxx\Documents\minecraft\code\mcpi_e\util.py

from the line 5 of code you will see
if isinstance(e, collections.Iterable) and not isinstance(e, str):

replace it into:
if isinstance(e, collections.abc.Iterable) and not isinstance(e, str):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants