如何将 pywin32 与 virtualenv 一起使用,而不必包含主机环境的站点包文件夹?
我正在 Python 2.6 下使用 PyInstaller,由于 MS 的清单造成了混乱,因此仅部分支持该版本现在影响 Python 的废话,因为它现在是 MSVC8 编译的。
问题是清单嵌入支持依赖于 pywin32 扩展才能构建,这是一个痛苦,因为当我创建 virtualenv (在构建环境中有点失败)我找不到安装所需扩展的方法,以便 PyInstaller 可以访问它们。
有没有人找到这个问题的解决方案?
I'm working with PyInstaller under Python 2.6, which is only partially supported due to the mess MS have created with their manifest nonense which now affects Python since it is now MSVC8 compiled.
The problem is that the manifest embedding support relies on the pywin32 extensions in order to build which is a pain because without including the host's site-packages folder when I create the virtualenv (kinda defeats the point in a build environment) I cannot find a way to install the required extensions so they are accessible to PyInstaller.
Has anyone found a solution to this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我发现 http://old.nabble.com/Windows:- virtualenv-and-pywin32--td27658201.html(现在是死链接),它提供了以下解决方案:
easy_install http://PATH.TO/EXE/DOWNLOAD
这适用于现代版本的 setuptools(大约 2014 年 2 月,由 tovmeod 在评论中报告)。
如果您使用的是旧版本的 setuptools(或将其分发合并回 setuptools),您可能会收到以下错误消息:
在这种情况下:
easy_install DOWNLOADED_FILE.exe
我宁愿尝试“pip install”而不是“easy_install”,但这不起作用,而且可能永远不会起作用(需要引用)。
最后,我在 http:// /www.mail-archive.com/[电子邮件受保护]/msg272040.html 这是:
如果其他选项不适合您,也许这个可以?
I found http://old.nabble.com/Windows:-virtualenv-and-pywin32--td27658201.html (now a dead link) which offered the following solution:
easy_install http://PATH.TO/EXE/DOWNLOAD
This works with modern versions of setuptools (circa February 2014, reported by tovmeod in the comments).
If you are using an old version of setuptools (or distribute it merged back into setuptools), you may get this error message:
In which case:
easy_install DOWNLOADED_FILE.exe
I rather hopefully tried "pip install" rather than "easy_install", but this didn't work, and likely never will (citation needed).
Finally, I found but haven't tested a solution at http://www.mail-archive.com/[email protected]/msg272040.html which is:
If the other options don't work for you, maybe this will?
对于 Python 2.7 或 3.x,请使用 pypiwin32。
pip 安装 pypiwin32
For Python 2.7 or 3.x use pypiwin32.
pip install pypiwin32
好吧,既然我必须找到前进的道路,我就即兴发挥。我在内部创建了一个 git 存储库,其中包含 pywin32 的 hacked-together 版本,该存储库将使用标准
setup.py
脚本安装在 virtualenv 中。我花了很多功夫才使其正常工作,但我设法加载它,并且依赖的代码现在可以按照我的需要工作。如果人们认为这对社区有益,请发表评论:如果我得到足够的信息,我会尝试在我的 github 帐户上发布一些内容。OK, well since I had to find a way forward I improvised. I've internally created a git repository with a hacked-together version of pywin32 that will install within a virtualenv using the standard
setup.py
script. It took a lot of fiddling to make it work right but I managed to get it to load and the dependent code now works as I need it to. If people feel this would be of benefit to the community please post a comment: if I get enough I'll try and put something up on my github account.自之前的答案以来,这可能已经得到了改进,因为我已经在几台机器上的沙箱上成功安装了 pywin32,没有任何特定的“黑客”:
使用以下环境进行测试:
http://www.microsoft.com/en-us/download /details.aspx?id=44266
This may have been improved since previous answer, since I've successfully installed pywin32 on sandbox on several machines without any specific "hacks" :
Tested with following environment :
http://www.microsoft.com/en-us/download/details.aspx?id=44266
编辑:暂时解决这个问题,安装似乎仍然存在一些问题...
我对整个情况感到相当厌倦,只是创建了一组改装的轮子(“轮转换<.exe>”)。我会尽力在最新版本中维护它们,但如果有任何问题,请大声喊叫。
https://tr00st.co.uk/python/wheel/pywin32/
安装即可使用 pip 并指向与您的版本和体系结构匹配的包可以轻松完成。例如,对于 Python 3.5/amd64:
pip install https://tr00st.co.uk/python/wheel/pywin32/pywin32-219-cp35-none-win_amd64.whl
警告:--upgrade 过程当前失败,因为卸载过程无法自行清理(清理 win32api.pyd 时访问被拒绝) - 仅在删除临时目录时有效,可以手动删除临时目录。最简单的方法是卸载并重新安装而不是升级,然后手动删除临时文件夹。
Edit: Scratch this for now, appears to be some problems with the installation still...
I got rather tired of the whole situation, and just created a set of converted wheels ("wheel convert <.exe>"). I'll try and keep them maintained for the most recent build, but do shout if there are any issues.
https://tr00st.co.uk/python/wheel/pywin32/
Installation can be done easily using pip and pointing to the package matching your version and architecture. For example, for Python 3.5/amd64:
pip install https://tr00st.co.uk/python/wheel/pywin32/pywin32-219-cp35-none-win_amd64.whl
Caveat: The --upgrade process currently fails, as the uninstall procedure is unable to clean up after itself (Access Denied when cleaning up win32api.pyd) - this is only when removing the temporary directory, which can be manually deleted. Easiest way around this is to uninstall and reinstall instead of upgrading, then manually delete the temporary folder.