nicolargo / nvidia-ml-py3

Python 3 Bindings for the NVIDIA Management Library
133 stars 58 forks source link

AttributeError: module 'string' has no attribute 'join' in _PrintableStructure class #4

Closed SangY00n closed 1 year ago

SangY00n commented 1 year ago

Thank you for providing this library.

I'm posting this in hopes that it will help someone who may have the same problem as I did. When trying to print a class inherited from _PrintableStructure such as c_nvmlProcessInfo_t() using print(c_nvmlProcessInfo_t()), the following AttributeError occurred.

AttributeError: module 'string' has no attribute 'join'

This is because string.join() has been removed in python3. The problem was solved by changing the value returned from __str__ of the _PrintableStructure class in pynvml.py as follows.

Original: return self.__class__.__name__ + "(" + string.join(result, ", ") + ")"

Modified: return self.__class__.__name__ + "(" + ", ".join(result) + ")"