我在使用 ctypes 时遇到问题。我正在尝试让以下项目在 Vista 上运行。
http://sourceforge.net/projects/fractalfrost/
我之前在 Vista 上使用过该项目,没有出现任何问题。我没有看到 svn 中任何想法发生改变,我认为这是这台机器本地的东西。事实上,我根本无法使用 ctypes 加载 dll。
Bobby@Teresa-PC ~/fr0st-exe/fr0st/pyflam3/win32_dlls
$ ls
Flam4CUDA_LIB.dll cudart.dll glew32.dll libflam3.dll pthreadVC2.dll
Bobby@Teresa-PC ~/fr0st-exe/fr0st/pyflam3/win32_dlls
$ python
Python 2.6.3 (r263rc1:75186, Oct 2 2009, 20:40:30) [MSC v.1500 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> flam3_dll = CDLL('libflam3.dll')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python26\lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 5] Access is denied
>>> flam3_dll = CDLL('.\\libflam3.dll')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python26\lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 5] Access is denied
>>> import os
>>> flam3_dll = CDLL(os.path.abspath('libflam3.dll'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python26\lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 5] Access is denied
>>>
有什么想法会导致这个问题以及更好的解决办法吗?
最佳答案
我知道这听起来很愚蠢,但由于您没有明确提及:
您是否检查过您尝试访问的文件的权限?也许您没有该文件的读取或执行权限。
关于python - 在 Vista 上使用 ctypes 加载 dll 时访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1533466/