cubewise-code / tm1py

TM1py is a Python package that wraps the TM1 REST API in a simple to use library.
http://tm1py.readthedocs.io/en/latest/
MIT License
187 stars 107 forks source link

ModuleNotFoundError: No module named 'distutils' #1007

Closed bakerde-2024 closed 8 months ago

bakerde-2024 commented 8 months ago

Describe what did you try to do with TM1py ran python check.py

Describe what's not working the way you expect Expected questions for TM1 server information and got the following error ModuleNotFoundError: No module named 'distutils'

Version

Additional context PS C:\TM1py\tm1py-master\TM1py\tm1py-samples-master> python check.py Traceback (most recent call last): File "C:\TM1py\tm1py-master\TM1py\tm1py-samples-master\check.py", line 6, in from distutils.util import strtobool ModuleNotFoundError: No module named 'distutils' PS C:\TM1py\tm1py-master\TM1py\tm1py-samples-master>

0xWEBMILK commented 8 months ago

try: sudo apt-get install python3-distutils

bakerde-2024 commented 8 months ago

In a command prompt or Python? New to the TM1py app and python.

0xWEBMILK commented 8 months ago

Enter this command in the command line (command prompt)

rkvinoth commented 8 months ago

With that question, I'm gonna believe that you are using a Windows OS.

I think you are using a virtual environment which gets created while using an IDE to open the folder as a project. To avoid this, you can close the IDE and open the folder in it again. But, this time use the native python interpreter and not a virtual environment.

bakerde-2024 commented 8 months ago

Yes, running on Windows OS. Downloaded and installed python from Microsoft store and ran the PIP to install TM1py. Opened a command prompt in the samples directory and ran python check.py. I will try reinstalling Python to see if it can fix the error.

TM1si commented 8 months ago

Maybe late, but anyway:

There is a missing module: distutils Many examples rely on Python before V 3.10. With this version module distutils was depriated, but remained in installation libs. In version 3.12 module distutils was removed. Threfore this results in an error

In most cases you only need function strtobool. For this you have the alternative

pip install str2bool

Then replace distutils by strtobool and str2bool. Like this:


from str2bool import str2bool
from TM1py.Services import TM1Service

ssl = str2bool("F")