pysc2
pysc2 copied to clipboard
TypeError: Descriptors cannot not be created directly.
I'm getting this error when trying to use pysc2. This happens with both the pip install and trying to use it from git.
cli command:
pysc2_replay_info --replay ~/replays/15467fbf7779f05d783c8b384411dfeb.SC2Replay
traceback:
Traceback (most recent call last):
File "/home/ashley/.local/bin/pysc2_replay_info", line 5, in <module>
from pysc2.bin.replay_info import entry_point
File "/home/ashley/.local/pipx/venvs/pysc2/lib/python3.11/site-packages/pysc2/bin/replay_info.py", line 22, in <module>
from pysc2 import run_configs
File "/home/ashley/.local/pipx/venvs/pysc2/lib/python3.11/site-packages/pysc2/run_configs/__init__.py", line 18, in <module>
from pysc2.lib import sc_process
File "/home/ashley/.local/pipx/venvs/pysc2/lib/python3.11/site-packages/pysc2/lib/sc_process.py", line 27, in <module>
from pysc2.lib import remote_controller
File "/home/ashley/.local/pipx/venvs/pysc2/lib/python3.11/site-packages/pysc2/lib/remote_controller.py", line 24, in <module>
from pysc2.lib import protocol
File "/home/ashley/.local/pipx/venvs/pysc2/lib/python3.11/site-packages/pysc2/lib/protocol.py", line 29, in <module>
from s2clientprotocol import sc2api_pb2 as sc_pb
File "/home/ashley/.local/pipx/venvs/pysc2/lib/python3.11/site-packages/s2clientprotocol/sc2api_pb2.py", line 17, in <module>
from s2clientprotocol import common_pb2 as s2clientprotocol_dot_common__pb2
File "/home/ashley/.local/pipx/venvs/pysc2/lib/python3.11/site-packages/s2clientprotocol/common_pb2.py", line 32, in <module>
_descriptor.EnumValueDescriptor(
File "/home/ashley/.local/pipx/venvs/pysc2/lib/python3.11/site-packages/google/protobuf/descriptor.py", line 796, in __new__
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
same problem.
I met this problem at the first time too. Using python 3.9 and protobuf 3.19.6 can solve it.
To be more specific, this works to me:
pip install protobuf==3.20.0
To be more specific, this works to me:
pip install protobuf==3.20.0
This has also solved my problem! Using python 3.10.5
and pysc2 4.0.0