Author Topic: import _win32sysloader: ImportError: DLL load failed  (Read 9301 times)

Vitaliy

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
import _win32sysloader: ImportError: DLL load failed
« on: April 11, 2011, 07:19:32 AM »
Hello everyone!

I have a problem to run pyxll on fresh PC.  I have two PCs and I develop my pyxll project on one of them. Then, I want to run my project on the second one. I intalled Python and all site-packages I need. Then I try to run my project and have this:
----
 ERROR : Error calling function set_chk_all
2011-04-11 05:48:25,167 - ERROR : Traceback (most recent call last):
2011-04-11 05:48:25,167 - ERROR :   File "C:\PPSAS\modules\ppsas_progn.py", line 182, in set_chk_all
2011-04-11 05:48:25,167 - ERROR :     xl = xl_app()
2011-04-11 05:48:25,167 - ERROR :   File "C:\PPSAS\modules\ppsas_tools.py", line 87, in xl_app
2011-04-11 05:48:25,167 - ERROR :     xl_window = pyxll.GetActiveObject()
2011-04-11 05:48:25,167 - ERROR :   File "C:\Python27\lib\site-packages\pythoncom.py", line 2, in <module>
2011-04-11 05:48:25,167 - ERROR :     import pywintypes
2011-04-11 05:48:25,167 - ERROR :   File "C:\Python27\lib\site-packages\win32\lib\pywintypes.py", line 124, in <module>
2011-04-11 05:48:25,167 - ERROR :     __import_pywin32_system_module__("pywintypes", globals())
2011-04-11 05:48:25,167 - ERROR :   File "C:\Python27\lib\site-packages\win32\lib\pywintypes.py", line 64, in __import_pywin32_system_module__
2011-04-11 05:48:25,167 - ERROR :     import _win32sysloader
2011-04-11 05:48:25,167 - ERROR : ImportError: DLL load failed: Не найден указанный модуль. ("not found such module" -- vitaliy)
----

By the way, I intalled pyodbc (google module) and it doesn't work too:
----
2011-04-11 05:46:44,664 - ERROR : Error importing 'ppsas_accur': DLL load failed: Не найден указанный модуль.
2011-04-11 05:46:44,664 - ERROR : Traceback (most recent call last):
2011-04-11 05:46:44,664 - ERROR :   File "pyxll", line 402, in _open
2011-04-11 05:46:44,664 - ERROR :   File "C:\PPSAS\modules\ppsas_accur.py", line 2, in <module>
2011-04-11 05:46:44,664 - ERROR :     import pyodbc
2011-04-11 05:46:44,664 - ERROR : ImportError: DLL load failed: Не найден указанный модуль.
------

But, if I run python console all these modules imported correctly:
------
ActivePython 2.7.1.3 (ActiveState Software Inc.) based on
Python 2.7.1 (r271:86832, Dec  5 2010, 12:04:08) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
>>> import _win32sysloader
>>>
------

Reboot, rerun pyxll, reinstall python and other thing doesn't help.
Pyxll run correctly, it compile my python modules, but it seems that something bad happens with path or dll version of the files. I don't remember if I make any setup actions on my first PC, all things run properly here from the very first moment.

Any suggestions or help or trobleshooting?

Tony

  • Administrator
  • Hero Member
  • *****
  • Posts: 606
  • Karma: +14/-1
    • View Profile
Re: import _win32sysloader: ImportError: DLL load failed
« Reply #1 on: April 11, 2011, 07:50:49 AM »
Hi Vitaly,

I see you are using ActiveState Python 2.7.1.3. There were some problems to do with how extension dlls were built with some versions of Python 2.7 (to do with embedding manifests in the .pyd files that messes up loading the c runtime dll when imported outside of the normal python.exe).

Please could you install the lastest version of ActiveState Python (2.7.1.4) and see if you still get the same problem?

thanks,
Tony

Vitaliy

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: import _win32sysloader: ImportError: DLL load failed
« Reply #2 on: April 11, 2011, 08:09:21 AM »
Thanks for answer, Tony!

I have installed ActivePython 2.7.1.4, as you recommend and nothing happened. :(
Here, on PC where I run my pyxll project all things works properly with 2.7.1.3.
I agree that problem concern with calling native python modules by external way.
Any other suggestions?

I forget to tell, that I use different version of MS Office on both PCs.
Where all things works properly I use Office 2010, where things goes wrong I use Office 2007.
« Last Edit: April 11, 2011, 10:09:34 AM by Vitaliy »

Tony

  • Administrator
  • Hero Member
  • *****
  • Posts: 606
  • Karma: +14/-1
    • View Profile
Re: import _win32sysloader: ImportError: DLL load failed
« Reply #3 on: April 11, 2011, 07:21:29 PM »
Hi Vitaly,

I expect that it's not able to find msvcrt90.dll. That's distributed as part of Excel 2010, but not Excel 2007. It's also distributed with some versions of Python, depending on how that distribution was built.

Please can you check to see if you have it anywhere? (possibly in C:\Python27) If it's not already in C:\Windows\System32 try copying it there and see if that fixes your problem.

If it's not that, the next thing to check is exactly what DLL can't be loaded. You can use dependency walker (www.dependencywalker.com) on the problematic .pyd file to check what dll dependencies it's missing.

cheers,
Tony

Vitaliy

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: import _win32sysloader: ImportError: DLL load failed
« Reply #4 on: April 12, 2011, 06:32:13 AM »
Hi, Tony!

I found several copys of msvcr90.dll on my PC. If I copy one of them:
      OriginalFilename   : MSVCR90.DLL
      ProductName   : Microsoft® Visual Studio® 2008
      ProductVersion   : 9.00.21022.50

Then Excel 2007 get "Runtime error", after it still start correctly, but my project still doesn't work. If I try to press my control in pyxll project, then I get "Runtime error" too (it means, that msvcr90.dll is matter). Possibly I should try with another version of msvcr90.dll. On my PC, where all things works properly there is no msvcr90.dll in Windows\system32 directory. But I have msvcr90.dll in Windows/winsxs directory, several copies in C\:Program Files (none of therm in MS Office directory). I don't understand which of them used by Excel 2010 or Python? Other suggestions?
« Last Edit: April 12, 2011, 06:35:41 AM by Vitaliy »

Tony

  • Administrator
  • Hero Member
  • *****
  • Posts: 606
  • Karma: +14/-1
    • View Profile
Re: import _win32sysloader: ImportError: DLL load failed
« Reply #5 on: April 12, 2011, 07:49:55 AM »
Hi Vitaly,

after copying the dll do you still have problems with win32com, or now are you just having problems with pyodbc?

It seems that there is a problem with pyodbc 2.1.8, and if you are using that version you should try an earlier version, 2.1.7
http://code.google.com/p/pyodbc/issues/detail?id=124

Don't forget to try dependency walker as well.

cheers,
Tony

Vitaliy

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: import _win32sysloader: ImportError: DLL load failed
« Reply #6 on: April 14, 2011, 07:02:45 AM »
Hi, Tony!

I just installed Office 2010 on my second PC and my project is working properly now.
Office 2010 installed in upgrade from Office 2007 mode. But for Office version early than 2010 I guess you need some additional dll (like msvcr90.dll) in pyxll install package (imho).

Tony, would you please port pyxll on Python 3.x version? ) and would you please make shortcut for reload pyxll? )

Best,
Vitaliy

Tony

  • Administrator
  • Hero Member
  • *****
  • Posts: 606
  • Karma: +14/-1
    • View Profile
Re: import _win32sysloader: ImportError: DLL load failed
« Reply #7 on: April 14, 2011, 08:11:30 AM »
Hi Vitaly,

PyXLL isn't built using msvcrt90, the dependency actually comes from the python modules and how they're built - which is down to the individual distribution. That's why I don't provide msvcrt90.dll as part of PyXLL and rely on it being installed by the python distribution if it's required - but clearly it must be missing from the latest activestate 2.7 release.

PyXLL supports many different python distributions using the same PyXLL binary (from the standard build from python.com to custom mingw gcc builds), and not all of those are dependent on this version of the c runtime.

Python 3 support will be added when there's enough demand to make it worth it. As many 3rd party packages are still only 2.x there hasn't been that much demand for it. If you need it done and would like to discuss commercial licensing contingent on Python 3 support being added, please email me at sales@pyxll.com and we can see if something can be worked out for you.

To add a keyboard shortcut for reloading, the simplest way is to write a macro function in python that calls pyxll.reload(), and then wrap that in the VBA function and add a keyboard shortcut to that. See http://www.pyxll.com/documentation/macros#callmacros for details of how to call a PyXLL macro from VBA. Unfortunately it's not possible to map a PyXLL macro to a shortcut key directly.

Best regards,
Tony