据我了解,我不能使用pip来安装/升级pywin32
,但pip install -U pypiwin32
是一种解决方法。
pywin32
现在托管在GitHub上。我对git
知之甚少,但知道它适用于二进制文件。有没有办法以编程方式升级pywin32
二进制文件?也就是说,pywin32
v221与Python v.3.6(64位)一起安装,程序应检查GitHub上的最新版本(v223)并下载pywin32-223.win-amd64-py3.6.exe
并安装它。到目前为止,我只能想到一个类似于网络的脚本,它将安装的版本与网络上的最新版本进行比较并采取相应的行动。我想知道是否有一个简单的解决方案。
答案 0 :(得分:3)
我可能会遗漏一些至关重要的事情,否则(几乎)问题中的每个陈述/假设似乎都是错误的:
为了演示以上所有内容,我创建了一个 VirtualEnv ,并在此基础上执行了一系列步骤:
<强>输出强>:
(py36x64_test) e:\Work\Dev\StackOverflow\q049398198>where python pip c:\Work\Dev\VEnvs\py36x64_test\Scripts\python.exe c:\Work\Dev\VEnvs\py36x64_test\Scripts\pip.exe (py36x64_test) e:\Work\Dev\StackOverflow\q049398198>python -c "import sys;print(sys.version)" 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] (py36x64_test) e:\Work\Dev\StackOverflow\q049398198>pip -V pip 9.0.3 from c:\work\dev\venvs\py36x64_test\lib\site-packages (python 3.6) (py36x64_test) e:\Work\Dev\StackOverflow\q049398198>rem pip test (py36x64_test) e:\Work\Dev\StackOverflow\q049398198>pip list 2>nul | findstr pywin32 (py36x64_test) e:\Work\Dev\StackOverflow\q049398198>pip download -vvv pywin32 2>nul | findstr /i download Downloading pywin32-223-cp36-cp36m-win_amd64.whl (9.0MB) Downloading from URL https://pypi.python.org/packages/9f/9d/f4b2170e8ff5d825cd4398856fee88f6c70c60bce0aa8411ed17c1e1b21f/pywin32-223-cp36-cp36m-win_amd64.whl#md5=2d211288ee000b6ec5d37436bcbe8a43 (from https://pypi.python.org/simple/pywin32/) Successfully downloaded pywin32 (py36x64_test) e:\Work\Dev\StackOverflow\q049398198>pip install https://pypi.python.org/packages/be/25/0e0c568456b77ce144dd2b8799f915b046ffa1cd922771d214e4be05bca2/pywin32-222-cp36-cp36m-win_amd64.whl#md5=94a9a3782081e14973c5ae448957d530 2>nul Collecting pywin32==222 from https://pypi.python.org/packages/be/25/0e0c568456b77ce144dd2b8799f915b046ffa1cd922771d214e4be05bca2/pywin32-222-cp36-cp36m-win_amd64.whl#md5=94a9a3782081e14973c5ae448957d530 Downloading pywin32-222-cp36-cp36m-win_amd64.whl (9.0MB) 100% |################################| 9.0MB 135kB/s Installing collected packages: pywin32 Successfully installed pywin32-222 (py36x64_test) e:\Work\Dev\StackOverflow\q049398198>rem pip test (py36x64_test) e:\Work\Dev\StackOverflow\q049398198>pip list 2>nul | findstr pywin32 pywin32 (222) (py36x64_test) e:\Work\Dev\StackOverflow\q049398198>rem pywin32 test (py36x64_test) e:\Work\Dev\StackOverflow\q049398198>python -c "import win32api as wapi;print(wapi.GetFileVersionInfo(wapi.__file__, \"\\\\\")[\"FileVersionLS\"] >> 16)" 222 (py36x64_test) e:\Work\Dev\StackOverflow\q049398198>pip install -U pywin32 2>nul Collecting pywin32 Using cached pywin32-223-cp36-cp36m-win_amd64.whl Installing collected packages: pywin32 Found existing installation: pywin32 222 Uninstalling pywin32-222: Successfully uninstalled pywin32-222 (py36x64_test) e:\Work\Dev\StackOverflow\q049398198>rem pip test (py36x64_test) e:\Work\Dev\StackOverflow\q049398198>pip list 2>nul | findstr pywin32 pywin32 (223) (py36x64_test) e:\Work\Dev\StackOverflow\q049398198>rem pywin32 test (py36x64_test) e:\Work\Dev\StackOverflow\q049398198>python -c "import win32api as wapi;print(wapi.GetFileVersionInfo(wapi.__file__, \"\\\\\")[\"FileVersionLS\"] >> 16)" 223
答案 1 :(得分:1)
您可以使用Chocolatey及其pywin32 package,但它已过期。
因此,作为one described in this article的脚本解决方案(对于其他程序,但具有类似的想法)是可能的。另见this gist
如果您在任意位置解压缩latest Git for Windows并使用 simplified PATH
,则可以访问200多个Linux命令,包括awk
,{{1}等等。