cunnane / xloil

xlOil provides framework for interacting with Excel in different programming languages (python & C++ currently)
Other
126 stars 11 forks source link

xloil python init failed #104

Open huche6 opened 3 months ago

huche6 commented 3 months ago

I am trying to use xloil to work with a 32-bit Excel version. I downloaded in a virtual env python3.10 in a 32-bit version and installed xloil. When I'm trying to run Excel, I am getting the following error:

[2024-06-10 14:34:31.528] [logger] [debug] [Main.cpp:299] Python importing xloil
[2024-06-10 14:34:31.534] [logger] [error] [Main.cpp:408] xloil_python_init failed: ImportError: ImportError: DLL load failed while importing _ctypes: The specified module cannot be found.
Traceback (most recent call last):
  File "C:\Users\Hugo\micromamba\envs\xloil0\lib\site-packages\xloil\__init__.py", line 2, in <module>
    from ._core import *
  File "C:\Users\Hugo\micromamba\envs\xloil0\lib\site-packages\xloil\_core.py", line 19, in <module>
    env_vars = _get_environment_strings()
  File "C:\Users\Hugo\micromamba\envs\xloil0\lib\site-packages\xloil\_paths.py", line 46, in _get_environment_strings
    import ctypes
  File "C:\Users\Hugo\micromamba\envs\xloil0\lib\ctypes\__init__.py", line 8, in <module>
    from _ctypes import Union, Structure, Array
ImportError: DLL load failed while importing _ctypes: The specified module cannot be found.

The weird part is, if I activate my environnement and open a python consol, I can perform the faulty commands without problem. Do you have an idea from where the problem could come ?

I am working with: 32-bits Excel in Microsoft 365 Apps for enterprise Python 3.10.4 in 32-bits xloil 0.18.3 Windows 10

Great work for Xloil and thank you in advance !

P.S. It works without any problem with everything in 64-bits, I just have to use 32-bits version for a precise reason

cunnane commented 3 months ago

Could you check where _ctypes.pyd lives in your python distribution? It's normally in the DLLs directory. I suspect that certain environment paths aren't getting correctly set because you're using an environment different from the standard one or anaconda. xlOil should be able to cope with different environments, so I just want to establish what's going on.

huche6 commented 3 months ago

Thank you for your answer. The _ctypes.pyd is in the DLLs directory

cunnane commented 3 months ago

Could you try adding the path to the DLLs directory to your PYTHONPATH in your xloil.ini?