Register Py Module Error - New xlSlim User

87 views
Skip to first unread message

Harsha Gurram

unread,
Jun 4, 2023, 3:04:23 PM6/4/23
to xlSlim Support
After completing the setup instructions, I tried to register the python file using an absolute path:'=RegisterPyModule("C:\Users\HarshaGurram\Documents\Automation\myproject\myproject.py")' in excel. 

However, I was hit with the following error: 
  • #ERR The function call failed - The type initializer for 'Delegates' threw an exception.

I am not quite sure how to fix the following problem. I will paste the code in myproject.py below. But, I don't believe the issue is a result of the code in the file. 

def double_sum(x, y):
    """Returns twice the sum of the two arguments"""
    return 2 * (x + y) 

xlSlim Dev

unread,
Jun 4, 2023, 4:17:32 PM6/4/23
to xlSlim Support
Hi,

Thank you for giving xlSlim a try.

I created a new file with just your double_sum() function. I was able to register the file using RegisterPyModule() without issue and the function works within Excel.

I have not seen " The type initializer for 'Delegates' threw an exception." before.

Could you send me a copies of your log files please? The log files will be C:\Users\HarshaGurram\AppData\Roaming\Microsoft\AddIns\xlSlim\xlslim-addin.log and C:\Users\HarshaGurram\AppData\Roaming\Microsoft\AddIns\xlSlim\xlslim-python.log

Could you also please download the samples from github: https://github.com/RusselWebber/xlslim-code-samples/archive/refs/heads/main.zip and unzip the archive.

Then see if the quickstart sample works for you please? The Excel book is basics\quickstart.xlsx

Thank you,
Russel

Harsha Gurram

unread,
Jun 4, 2023, 8:50:34 PM6/4/23
to xlSlim Support
Hey Russel, 

Same error occurred when trying the quickstart excel sheet in the basics folder.  Attached is the requested log file. Also attached is a picture of the excel with the error. Please let me know if you need more information. 

Best, 
Harsha 
xlslim-addin.log
error_picture.png

xlSlim Dev

unread,
Jun 5, 2023, 4:52:14 AM6/5/23
to Harsha Gurram, xlSlim Support
Hi,
Thank you for the information. That looks like the built in Python 3.10 failing to initialise. Do you have a local Python installation (3.7 to 3.11 supported) that you could pass into RegisterPyModule() as the second parameter? Would be interesting to see if that works for you.
Thanks,
Russel 

--
You received this message because you are subscribed to the Google Groups "xlSlim Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xlslim-suppor...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/xlslim-support/426c7e1b-ae1b-4f95-946f-61c8cf67963fn%40googlegroups.com.

xlSlim Dev

unread,
Jun 5, 2023, 1:54:42 PM6/5/23
to xlSlim Support
Hi Harsha,

Could you check that you have a folder  C:\Users\HarshaGurram\AppData\Local\python-3.10.0-embed-amd64 please?

If you do then please double click on python.exe within the folder and verify that it opens ok. You should see:

Screenshot 2023-06-05 185254.png
If Python fails to start, could you try install the Visual C runtime redistribution from Microsoft? https://aka.ms/vs/17/release/vc_redist.x64.exe

Thank you for your help,
Russel

Harsha Gurram

unread,
Jun 5, 2023, 4:50:53 PM6/5/23
to xlSlim Support
Hey Russel, 

I checked on the two things that you suggested. 

  1. I tried to pass in the python installation as the second parameter in the RegisterPy() Module. First, I passed in the 3.11 installation I currently have on my windows PC. This crashed my excel instantly. I tried it about 4-5 times with the same result every time. In one of those instanced it raised a new error (listed in sub-bullet and log file attached)
  2. The folder you mentioned does exist. The python 10 exe file seems to work as shown in the picture. I also passed in the path for this as the second parameter and found it to also crash my excel.  

Also, I forgot to mention, in our previous corrospondence, that I couldn't find the xslim python error log in the indicated folder.  Let me know if you want me to try anything else! I would love for this to work as intended! 

Best, 
Harsha Gurram 

xlslim-addin.log

Harsha Gurram

unread,
Jun 5, 2023, 5:00:21 PM6/5/23
to xlSlim Support
Also, I wanted to include some of the excel log information (that indicate) crashing in case if it is of help. 
  • Application Error
    • Faulting application name: EXCEL.EXE, version: 16.0.16501.20196, time stamp: 0x6477f40c
      Faulting module name: clr.dll, version: 4.8.4614.0, time stamp: 0x63995bc5
      Exception code: 0xc0000005
      Fault offset: 0x0000000000682e80
      Faulting process id: 0x5e60
      Faulting application start time: 0x01d997efb94b3f04
      Faulting application path: C:\Program Files\Microsoft Office\Root\Office16\EXCEL.EXE
      Faulting module path: C:\Wi
    • ndows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
      Report Id: e96eaf99-86ed-45e1-a67b-38c49622a908
      Faulting package full name:
      Faulting package-relative application ID:
  •  Application Hang
    • The program EXCEL.EXE version 16.0.16501.20196 stopped interacting with Windows and was closed. To see if more information about the problem is available, check the problem history in the Security and Maintenance control panel.
       Process ID: 3ee4
       Start Time: 01d997ed5070f319
       Termination Time: 47
       Application Path: C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE
       Report Id: dcdadfff-03c8-4a7d-ae70-b9edda92b208
       Faulting package full name:
       Faulting package-relative application ID:
       Hang type: Unknown
Best, 
Harsha Gurram

xlSlim Dev

unread,
Jun 6, 2023, 2:04:18 AM6/6/23
to Harsha Gurram, xlSlim Support
Hi Harsha,

Thank you for all the information. I have tested using exactly the same Excel version and everything works for me.

I am puzzled by this issue. It is something on the Python side as we can see the failure to load python310.DLL in the logs. I am wondering if it could be related to the Windows Store Python 3.11 installation. I can see references to this installation in the path. Is the Python 3.11 installation 64-bit? Could you try uninstalling the Python 3.11 installation?

Another possibility is antivirus. Your antivirus may be blocking access to some files. Could you check if there is anything pertinent in the antivirus logs please?

Thanks for your help, I would also really like to get this working for you!

All the best,
Russel 

xlSlim Dev

unread,
Jun 6, 2023, 4:02:27 PM6/6/23
to xlSlim Support
Hi,

After further investigation I can partially reproduce the behaviour you see. The only way I can get the same " The type initializer for 'Delegates' threw an exception" error is is when I install a 32-bit Python 3.11 and try to use that. Which does make me wonder if we are seeing a problem with 64-bit vs 32-bit executables and libraries. xlSlim only works with 64-bit Python and 64-bit Excel. Do you have perhaps have any 32-bit Python installations on your PC that may be causing an issue? This doesn't quite explain why the built-in Python also fails though. Anyhow, please let me know.

Thanks,
Russel

Harsha Gurram

unread,
Jun 8, 2023, 12:56:49 PM6/8/23
to xlSlim Support
Hey Russel, 

It looks like the problem is with the windows store installation of python after all. I deleted the windows store installation and installed python from the website. I restarted my laptop and everything seemed to work as expected!  Interestingly, the windows installation was 64 bit and my computer did not have any other 32 bit python installations. So, I am not quite sure why the windows store installation doesn't work. 

Thanks for all the help and your patience in troubleshooting the issue. I will reach out if I have any more questions. 

Best, 
Harsha Gurram  
Reply all
Reply to author
Forward
0 new messages