在 pyWin32 中搜索 Python 3.5.2 版本

Searching pyWin32 for Python 3.5.2 version

我正在尝试在 windows 7、64 位和 python 版本 3.5.2 上安装 pyWin32。我找不到 pyWin32。我从 http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyhook 下载并安装 pyWin32 文件并收到如下错误:

Exception:
Traceback (most recent call last):
File "C:\Users\nisarahmed.h\AppData\Local\Programs\Python\Python35-32\Lib\shutil.py", 
line 381, in _rmtree_unsafe os.unlink(fullname)
FileNotFoundError: [WinError 2] The system cannot find the file specified:

'C:\Users\NISARA~1.H\AppData\Local\Temp\pip-ditl64b5-unpack\pypiwin32-219-cp35-none-win32.whl'

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\nisarahmed.h\appdata\local\programs\python\python35-32\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args)
File "c:\users\nisarahmed.h\appdata\local\programs\python\python35-32\lib\site-packages\pip\commands\install.py", line 335, in run wb.build(autobuilding=True)
File "c:\users\nisarahmed.h\appdata\local\programs\python\python35-32\lib\site-packages\pip\wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder)
File "c:\users\nisarahmed.h\appdata\local\programs\python\python35-32\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies))
File "c:\users\nisarahmed.h\appdata\local\programs\python\python35-32\lib\site-packages\pip\req\req_set.py", line 620, in _prepare_file session=self.session, hashes=hashes)
File "c:\users\nisarahmed.h\appdata\local\programs\python\python35-32\lib\site-packages\pip\download.py", line 821, in unpack_url hashes=hashes
File "c:\users\nisarahmed.h\appdata\local\programs\python\python35-32\lib\site-packages\pip\download.py", line 671, in unpack_http_url rmtree(temp_dir)
File "c:\users\nisarahmed.h\appdata\local\programs\python\python35-32\lib\site-packages\pip\_vendor\retrying.py", line 49, in wrapped_f
return Retrying(*dargs, **dkw).call(f, *args, **kw)
File "c:\users\nisarahmed.h\appdata\local\programs\python\python35-32\lib\site-packages\pip\_vendor\retrying.py", line 212, in call
raise attempt.get()
File "c:\users\nisarahmed.h\appdata\local\programs\python\python35-32\lib\site-packages\pip\_vendor\retrying.py", line 247, in get six.reraise(self.value[0], self.value[1], self.value[2])
File "c:\users\nisarahmed.h\appdata\local\programs\python\python35-32\lib\site-packages\pip\_vendor\six.py", line 686, in reraise raise value
File "c:\users\nisarahmed.h\appdata\local\programs\python\python35-32\lib\site-packages\pip\_vendor\retrying.py", line 200, in call attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File "c:\users\nisarahmed.h\appdata\local\programs\python\python35-32\lib\site-packages\pip\utils\__init__.py", line 102, in rmtree onerror=rmtree_errorhandler) 
File "C:\Users\nisarahmed.h\AppData\Local\Programs\Python\Python35-32\Lib\shutil.py", line 488, in rmtree return _rmtree_unsafe(path, onerror) 
File "C:\Users\nisarahmed.h\AppData\Local\Programs\Python\Python35-32\Lib\shutil.py", line 383, in _rmtree_unsafe 
onerror(os.unlink, fullname, sys.exc_info()) 
File "c:\users\nisarahmed.h\appdata\local\programs\python\python35-32\lib\site-packages\pip\utils\__init__.py", line 110, in rmtree_errorhandler 
if os.stat(path).st_mode & stat.S_IREAD: 
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\Users\NISARA~1.H\AppData\Local\Temp\pip-ditl64b5-unpack\pypiwin32-219-cp35-none-win32.whl'

提前致谢

我遇到了同样的问题。我通过直接调用所需函数来规避问题,例如:

from ctypes import *

FILE_LIST_DIRECTORY = 0x1
FILE_SHARE_DELETE = 0x00000004
FILE_SHARE_READ = 0x00000001
FILE_SHARE_WRITE = 0x00000002
FILE_FLAG_BACKUP_SEMANTICS = 0x02000000

OPEN_EXISTING = 0x3

handle = windll.kernel32.CreateFileW(
     path,
     FILE_LIST_DIRECTORY,
     FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
     None,
     OPEN_EXISTING,
     FILE_FLAG_BACKUP_SEMANTICS,
     None
)

而不是:

import win32file
import win32con
hDir = win32file.CreateFile (
    path_to_watch,
    FILE_LIST_DIRECTORY,
    win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE | win32con.FILE_SHARE_DELETE,
    None,
    win32con.OPEN_EXISTING,
    win32con.FILE_FLAG_BACKUP_SEMANTICS,
    None
 )

我想查看目录中的更改。 Tim Golden examples 将 PyWin32 API 用于此确切目的,但我未能安装该软件包。

因为我只需要两个函数,所以我最终直接从 ctypes.windll.kernel32 引用了它们。对于更复杂的项目,这可能不可行。 Windows Developer Center 对所需的功能进行了详细的记录 well,因此很容易找到所需的标志。

请注意,您可能需要区分 unicode 和 ansi 名称,例如CreateFileW (Unicode) 和 CreateFileA (ANSI),寻找函数时。这让我有些困惑,因为我正在搜索 CreateFile 而不是 CreateFileW.

我从Whosebug找到了答案。 pip install pywin32 对我没用,但 pip install pypiwin32 对我有用。