在pyWin32中搜索python3.5.2版本

2024-06-25 23:23:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试在Windows7、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'

提前谢谢


Tags: pipinpylibpackageslocallinesite
2条回答

我从Stackoverflow找到了答案。pip install pywin32对我不起作用,但{}对我有用。在

我也有同样的问题。我通过直接调用所需的函数来避免这个问题,例如:

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
)

而不是:

^{pr2}$

我想看目录的变化。timgoldent有examples来使用pywin32api来实现这个目的,但是我未能安装这个包。在

由于我只需要两个函数,我最终直接从ctypes.windll.kernel32引用它们。对于更复杂的项目,这可能不可行。Windows开发人员中心记录了所需的函数well,因此很容易找到所需的标志。在

注意,在查找函数时,可能需要区分unicode和ansi名称,例如CreateFileW(unicode)和CreateFileA(ansi)。这给我带来了一些困惑,因为我搜索的是CreateFile,而不是{}。在

相关问题 更多 >