classification
Title: ctypes.util.find_library does not find all DLLs anymore
Type: behavior Stage: resolved
Components: ctypes, Windows Versions: Python 3.6, Python 3.3, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Sophist, loewis, marcusva, meador.inge, vyrus
Priority: normal Keywords:

Created on 2012-10-19 08:52 by marcusva, last changed 2017-05-13 11:46 by eryksun. This issue is now closed.

Files
File name Uploaded Description Edit
ct_test.py marcusva, 2012-10-19 08:52 Test script
Messages (4)
msg173315 - (view) Author: Marcus von Appen (marcusva) Date: 2012-10-19 08:52
ctypes.util.find_library does not seem to be able to find certain libraries in Python3.3 on Win32 platforms anymore, if the library suffix is omitted. For some reason, os.path.isfile() in ctypes.util.find_library returns False in those cases.

Please try out the attached test script. This produces the following output on a Windows 7 x64 system for me (given that a OpenAL32.dll is installed):


C:\>c:\Python27-x64\python.exe ct_test.py

Python build: 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)]
Path 'C:\Windows\system32' exists in $PATH: True
File 'C:\Windows\system32\OpenAL32.dll' exists: True
ctypes says for 'OpenAL32.dll': C:\Windows\system32\OpenAL32.dll
ctypes says for 'OpenAL32': C:\Windows\system32\OpenAL32.dll


C:\>c:\Python31-x64\python.exe ct_test.py

Python build: 3.1.4 (default, Jun 12 2011, 14:16:16) [MSC v.1500 64 bit (AMD64)]
Path 'C:\Windows\system32' exists in $PATH: True
File 'C:\Windows\system32\OpenAL32.dll' exists: True
ctypes says for 'OpenAL32.dll': C:\Windows\system32\OpenAL32.dll
ctypes says for 'OpenAL32': C:\Windows\system32\OpenAL32.dll

C:\>c:\Python32-x64\python.exe ct_test.py

Python build: 3.2.3 (default, Apr 11 2012, 07:12:16) [MSC v.1500 64 bit (AMD64)]
Path 'C:\Windows\system32' exists in $PATH: True
File 'C:\Windows\system32\OpenAL32.dll' exists: True
ctypes says for 'OpenAL32.dll': C:\Windows\system32\OpenAL32.dll
ctypes says for 'OpenAL32': C:\Windows\system32\OpenAL32.dll

C:\>c:\Python33-x64\python.exe ct_test.py

Python build: 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)]
Path 'C:\Windows\system32' exists in $PATH: True
File 'C:\Windows\system32\OpenAL32.dll' exists: True
ctypes says for 'OpenAL32.dll': C:\Windows\system32\OpenAL32.dll
ctypes says for 'OpenAL32': None
msg223200 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-07-16 13:47
Works fine for me.

Python build: 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)]
Path 'C:\Windows\system32' exists in $PATH: True
File 'C:\Windows\system32\acledit.dll' exists: True
ctypes says for 'acledit.dll': C:\Windows\system32\acledit.dll
ctypes says for 'acledit': C:\Windows\system32\acledit.dll
msg293602 - (view) Author: Sophist (Sophist) Date: 2017-05-13 08:31
Finding it impossible for PIP to install discid.

Tracked it down to this issue i.e. os.path.isfile('C:\Windows\system32\discid.dll') == False when the dll exists.

Some other dlls in that directory result in True and some in False. I cannot see any significant difference in security permissions that might cause this - only difference is security permissions for some are inherited and some are not inherited.

I get this on both Python 3.6.1 32-bit and 2.7.13 32-bit on Win 10 Pro 64-bit Anniversary Edition 1607. I use ESET Smart Security 9 as AV.
msg293606 - (view) Author: Sophist (Sophist) Date: 2017-05-13 09:00
http://stackoverflow.com/questions/23125857/python-os-path-exists-cant-locate-the-file-however-the-file-indeed-exsits gave me an explanation:

That when running 32-bit apps on Win 64 C:\Windows\SysWOW64 is mapped to C:\Windows\system32.

Copying the missing DLL to SysWOW64 made it work.

NOTE: Original report was for 64-bit on 64-bit, so this is not necessarily an explanation of the original issue.
History
Date User Action Args
2017-05-13 11:46:05eryksunsetstatus: pending -> closed
2017-05-13 11:45:44eryksunsetstatus: open -> pending
resolution: out of date
stage: resolved
2017-05-13 11:30:09BreamoreBoysetnosy: - BreamoreBoy
2017-05-13 09:00:18Sophistsetmessages: + msg293606
2017-05-13 08:32:34Sophistsetversions: - Python 3.7
2017-05-13 08:32:10Sophistsetversions: + Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7
2017-05-13 08:31:07Sophistsetnosy: + Sophist
messages: + msg293602
2014-07-16 13:47:44BreamoreBoysetnosy: + BreamoreBoy
messages: + msg223200
components: + Windows
2013-01-04 23:01:09vyrussetnosy: + loewis, vyrus
2012-12-29 05:06:15meador.ingesetnosy: + meador.inge
2012-10-19 08:52:58marcusvacreate