Menu

#753 DLL load fails when on any drive other than C:

v1.0 (example)
open
nobody
None
5
2017-07-09
2017-07-03
David
No

If the current working directory is not in the C: drive, then importing the win32api module will fail.

I:\>python
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32api
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified path is invalid.
>>> quit()

I:\>C:

C:\>python
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32api
>>> # No traceback is appears.
>>> quit()

C:\>

As you can see in the example above, when the command prompt is in the I: drive, the import statement fails. If the user switches to the C: drive and tries again, then the import statement succeeds.

Discussion

  • Mark Hammond

    Mark Hammond - 2017-07-03

    This works fine for me - I'm guessing something in your environment (eg, PATH) has a relative path rather than a fully-qualified path which includes the drive letter.

     
  • David

    David - 2017-07-05

    I tried it on another machine, and the problem did not occur. That machine was running Windows 10. The machine where the problem occurred was running Windows 7. What version of Windows did you use to test?

     
  • David

    David - 2017-07-05

    I checked the PATH variable on the Windows 7 machine, and all of the paths in PATH are absolute.

     
  • Mark Hammond

    Mark Hammond - 2017-07-05

    My development machine still runs Windows 7

     
  • David

    David - 2017-07-09

    Hm, here is the full PATH variable. I'll try to spot which DLL is failing to load on Monday.

    C:\Program Files\Python36\Scripts\
    C:\Program Files\Python36\
    C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
    C:\Windows\system32
    C:\Windows
    C:\Windows\System32\Wbem
    C:\Windows\System32\WindowsPowerShell\v1.0\
    C:\Windows\CCM
    "C:\Program Files (x86)\Common Files\EMC"
    C:\Windows\CCM
    C:\Windows\CCM
    C:\Windows\CCM
    C:\Windows\CCM
    C:\Windows\CCM
    C:\Program Files (x86)\Common Files\EMC\
    C:\Windows\CCM
    C:\Windows\System32\WindowsPowerShell\v1.0\
    
     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.