Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ghost opened this issue Jul 3, 2017 · 6 comments
Closed

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

ghost opened this issue Jul 3, 2017 · 6 comments

Comments

@ghost
Copy link

ghost commented Jul 3, 2017

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.

Reported by: wecsam

Original Ticket: pywin32/bugs/753

@ghost
Copy link
Author

ghost commented Jul 3, 2017

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.

Original comment by: mhammond

@ghost
Copy link
Author

ghost commented Jul 5, 2017

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?

Original comment by: wecsam

@ghost
Copy link
Author

ghost commented Jul 5, 2017

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

Original comment by: wecsam

@ghost
Copy link
Author

ghost commented Jul 5, 2017

My development machine still runs Windows 7

Original comment by: mhammond

@ghost
Copy link
Author

ghost commented Jul 9, 2017

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\

Original comment by: wecsam

@ghost ghost assigned ghost and unassigned ghost Oct 24, 2017
@Avasam
Copy link
Collaborator

Avasam commented Mar 17, 2024

Since 71afa71, the PATH is now prepended, rather than appended. For Python >= 3.8, the PATH environment variable isn't even used. This is included in pywin32==226.

Python 3.7 has also reached EOL (meaning no security fixes/support) and I'd recommend migrating over to 3.8+ (see #2207)

.exe installers are now deprecated #1939, so you should install from PyPI (ie: pip install pywin32>=226)

Given the sheer amount of "ImportError: DLL load failed" issue duplication and old history, I'd like to consolidate the current state of these issues. So I'll close and reference back any issue that only has comments showing the issue:

  • from before November 10th, 2019 (pywin32<226)
  • using .exe installers
  • using Python < 3.8

Please also try https://github.com/mhammond/pywin32#troubleshooting before opening a new issue, or let us, and others, know if it did resolve your issue.

@Avasam Avasam closed this as completed Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant