Enmscript to connect to ENM CLI using enmscripting package

Hi,

I am executing an python Script that tend to connect with ENM CLI, I followed all steps in Ericsson Liberary but I encounter those Errors, I appreciate any Help !! Thanks in advance.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Traceback (most recent call last):
File “ENM_Command.py”, line 1, in
File “”, line 1360, in _find_and_load
File “”, line 1331, in _find_and_load_unlocked
File “”, line 935, in load_unlocked
File “PyInstaller\loader\pyimod02_importers.py”, line 419, in exec_module
File "enmscripting_init
.py", line 2, in
File “”, line 1360, in _find_and_load
File “”, line 1331, in _find_and_load_unlocked
File “”, line 935, in _load_unlocked
File “PyInstaller\loader\pyimod02_importers.py”, line 419, in exec_module
File “enmscripting\enmscripting.py”, line 4, in
File “”, line 1360, in _find_and_load
File “”, line 1331, in _find_and_load_unlocked
File “”, line 935, in _load_unlocked
File “PyInstaller\loader\pyimod02_importers.py”, line 419, in exec_module
File “enmscripting\private\session.py”, line 14, in
File “”, line 1360, in _find_and_load
File “”, line 1331, in _find_and_load_unlocked
File “”, line 935, in _load_unlocked
File “PyInstaller\loader\pyimod02_importers.py”, line 419, in exec_module
File “enmscripting\security\authenticator.py”, line 50, in
File “enmscripting\security\authenticator.py”, line 63, in UsernameAndPassword
File “enmscripting\private\overrides.py”, line 26, in overrides
TypeError: ‘NoneType’ object is not subscriptable
[16104] Failed to execute script ‘ENM_Command’ due to unhandled exception!
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ENM_Command is my python Script.!!

Hi, @Jemmy, are you running it from scripting VM? Is it python 2 or 3?

No, I am running it from ENM Deployment, and I am using Python 3.

Hi, @Jemmy!
It seems to me that you need to find the reason for this error: “TypeError: ‘NoneType’ object is not subscriptable”. Some object cannot be created or does not find it in the ENM.

Hi @Nekto thanks in advance, but why should That happen. I mean is the problem due to enmscripting package ??

Are you entering your credentials then creating enmscripting?

session = enmscripting.open(enm_url, username, password)

Possible reason is PyInstaller used: " If the function is called from a frame that does not have a valid stack frame, inspect.stack() may return None . This can happen if the function is called from a non-Python context or if the frame is not properly set up."

Hi, This my python Script.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++
import enmscripting as enm

session = enm.open('https://abc.com', 'Jemmy', 'XXX!')
command = 'cmedit get * -t'                          
cmd = session.command()
response = cmd.execute(command)
print('The command was Successfully sent and a response received: ' + str(response.is_command_result_available()))
print('HTTP_Code : ' + str(response.http_response_code()))
enm.close(session)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++

But after some troubleshooting, I still facing the following error : 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Traceback (most recent call last):
  File "C:\Users\Jemmy\OneDrive\Images\ENM_Command.py", line 1, in <module>
    import enmscripting as enm
  File "C:\Users\Jemmy\AppData\Local\Programs\Python\Python312\Lib\site-packages\enmscripting\__init__.py", line 2, in <module>
    from .enmscripting import (open, close)
  File "C:\Users\Jemmy\AppData\Local\Programs\Python\Python312\Lib\site-packages\enmscripting\enmscripting.py", line 4, in <module>
    from .private import session
  File "C:\Users\Jemmy\AppData\Local\Programs\Python\Python312\Lib\site-packages\enmscripting\private\session.py", line 5, in <module>
    import requests
  File "C:\Users\Jemmy\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\__init__.py", line 58, in <module>
    from . import utils
  File "C:\Users\Jemmy\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\utils.py", line 30, in <module>
    from .cookies import RequestsCookieJar, cookiejar_from_dict
  File "C:\Users\Jemmy\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\cookies.py", line 159, in <module>
    class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'collections' has no attribute 'MutableMapping'
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

I do have python version 3.12.2
And a requets package version 2.6.0

So what may be the issue?
Thanks in advance

Hi, @Jemmy, I can confirm enmscripting 1.21 and up supports python 3.5-3.8. Version 3.12 I believe not supported. Issue you faced with answered in stackoverflow " The attribute MutableMapping from the module collections got moved into collections.abc in python3.10 ."