我正在尝试在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'
提前致谢
答案 0 :(得分:0)
我有同样的问题。我通过直接调用所需的函数来规避问题,例如:
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开发人员中心非常详细地记录了所需的功能well,因此很容易找到所需的标记。
请注意,您可能必须区分unicode和ansi名称,例如在查找函数时,CreateFileW(Unicode)和CreateFileA(ANSI)。这对我造成了一些困惑,因为我正在搜索CreateFile
而不是CreateFileW
。
答案 1 :(得分:0)
我从Stackoverflow找到答案。 pip install pywin32
pip install pypiwin32
对我无效,但.git/
确实如此。