Typeerror: descriptors can not be created directly error occurs because of incompatibility of protobuf package. This incompatibility can be direct or because of any other python module. Basically, there are multiple python packages that invoke the internally protobuf module. For example, googleapis-common-protos package is internally dependent on protobuf module. Somehow we downgrade or upgrade this googleapis-common-protos package which can cause incompatibility of protobuf module. There are multiple ways to fix this issue. In this article, we will figure them out. So let’s begin –
Typeerror: descriptors cannot not be created directly ( Solution )-
There are multiple layers of solutions to fix this issue. We should start from the first and move ahead to fix this descriptors cannot not be created directly error.
Solution 1 : upgrade/ downgrade protobuf to 3.20.x version-
Mostly this incompatibility was observed in protobuf 4. x.x series which was immediately released after 3.20.x series. There are multiple releases of protobuf in 4. x.x but the most stable version was 3.30.x series. So if you are currently on protobuf 4. x.x series, Please downgrade to 3.20.x series. On the opposite side, if the protobuf version is lower than 3.19.x or equal then you need to upgrade this protobuf package. Here is the command to support compatibility.
pip install protobuf==3.20.0
pip install 'protobuf<=3.20.1' --force-reinstall
Solution 2: Upgrade the invoking module –
This solution will work if you are invoking indirectly protobuf module. For example wandb, googleapis-common-protos etc which internally usages protobuf module. If you are facing incompatibility then upgrade the same package to the latest version.
Solution 3: Use the Virtual Environment –
If you are using multiple projects at the same python version, Suppose you upgrade protobuf or any other module which was internally invoked by some other package. Then it can cause incompatibility and throw similar types of typeerrors.
Similar Articles :
1.Typeerror module object is not callable : How to Fix?
2.typeerror dataframe object is not callable : Quickly Fix It
3.typeerror: exceptions must derive from baseexception – Fix Quickly
Data Science Learner Team
Join our list
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.