How to install pywin32 in virtualenv with python 2.7 64 bit?
我想知道使用64位python 2.7 pywin32模块(操作系统是Windows 7 64位)在virtualenv上进行安装的正确方法。
我在Sourceforge上找到了exe安装程序。
当我首先在命令行上运行easy_installer时,一切都很好,但很快我看到了奇怪的行为:当pywin32-216.win-amd64-py2.7安装时,它运行pywin32-216-py2.7-win32.egg,并失败并显示错误:
1 2 | No local packages or download links found for pywin32==216 Best match: None |
这是我的完整日志:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | (sandbox_virtenv) D:\test\py2exe_test>easy_install http://sourceforge.net/projects/pywin32/files/pywin32/Build216/pywin32-216.win-amd64-py2.7.exe Downloading http://sourceforge.net/projects/pywin32/files/pywin32/Build216/pywin32-216.win-amd64-py2.7.exe Processing pywin32-216.win-amd64-py2.7.exe pywintypes: module references __file__ win32evtlogutil: module references __file__ win32serviceutil: module references __file__ win32timezone: module references __file__ Demos.win32rcparser_demo: module references __file__ Demos.security.sspi.validate_password: module references __file__ isapi.install: module references __file__ isapi.samples.advanced: module references __file__ isapi.samples.test: module references __file__ isapi.test.setup: module references __file__ pywin.framework.scriptutils: module references __file__ pywin.framework.startup: module references __path__ pywin.scintilla.config: module references __path__ pywin.scintilla.control: module references __file__ pywin.scintilla.IDLEenvironment: module references __file__ scripts.regsetup: module references __file__ scripts.setup_d: module references __file__ test.testall: module references __file__ test.test_clipboard: module references __file__ test.test_win32api: module references __file__ test.test_win32rcparser: module references __file__ D:\test\sandbox_virtenv\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\command\bdist_egg.py:422: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal symbols = dict.fromkeys(iter_symbols(code)) test.test_win32trace: module references __file__ win32com.__init__: module references __path__ win32com.server.register: module references __file__ win32com.server.register: module references __path__ win32com.test.GenTestScripts: module references __path__ win32com.test.pippo_server: module references __file__ win32com.test.testall: module references __file__ win32com.test.testAXScript: module references __path__ win32com.test.testDictionary: module references __file__ win32com.test.testPippo: module references __file__ win32com.test.testPyComTest: module references __file__ win32com.test.testServers: module references __file__ win32com.test.util: module references __file__ win32comext.adsi.__init__: module references __path__ win32comext.authorization.__init__: module references __path__ win32comext.axcontrol.__init__: module references __path__ win32comext.axdebug.codecontainer: module references __file__ win32comext.axdebug.debugger: module references __file__ win32comext.axdebug.__init__: module references __path__ win32comext.axscript.__init__: module references __path__ win32comext.bits.__init__: module references __path__ win32comext.directsound.__init__: module references __path__ win32comext.directsound.test.ds_test: module references __file__ win32comext.internet.__init__: module references __path__ win32comext.mapi.__init__: module references __path__ win32comext.shell.__init__: module references __path__ win32comext.shell.demos.servers.empty_volume_cache: module references __file__ win32comext.shell.demos.servers.folder_view: module references __file__ win32comext.taskscheduler.__init__: module references __path__ creating 'c:\users\antp~1.kyi\appdata\local\temp\easy_install-kclmxk\pywin32-216-py2.7-win32.egg' and adding 'c:\users\antp~1.kyi\appdata\local\temp\easy_install-kclmxk\pywin32-216-py2.7-win32.egg.tmp' to it creating d:\test\sandbox_virtenv\lib\site-packages\pywin32-216-py2.7-win32.egg Extracting pywin32-216-py2.7-win32.egg to d:\test\sandbox_virtenv\lib\site-packages Adding pywin32 216 to easy-install.pth file Installing pywin32_postinstall.py script to D:\test\sandbox_virtenv\Scripts Installing pywin32_postinstall.pyc script to D:\test\sandbox_virtenv\Scripts Installing pywin32_testall.py script to D:\test\sandbox_virtenv\Scripts Installing pywin32_testall.pyc script to D:\test\sandbox_virtenv\Scripts Installed d:\test\sandbox_virtenv\lib\site-packages\pywin32-216-py2.7-win32.egg Processing dependencies for pywin32==216 Searching for pywin32==216 Reading http://pypi.python.org/simple/pywin32/ Reading http://sf.net/projects/pywin32 Reading https://sourceforge.net/projects/pywin32/files/pywin32/ Reading http://sourceforge.net/project/showfiles.php?group_id=78018 No local packages or download links found for pywin32==216 Best match: None Traceback (most recent call last): File"D:\test\sandbox_virtenv\Scripts\easy_install-script.py", line 8, in <module> load_entry_point('setuptools==0.6c11', 'console_scripts', 'easy_install')() File"D:\test\sandbox_virtenv\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\command\easy_install.py", line 1712, in main with_ei_usage(lambda: File"D:\test\sandbox_virtenv\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\command\easy_install.py", line 1700, in with_ei_usage return f() File"D:\test\sandbox_virtenv\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\command\easy_install.py", line 1716, in <lambda> distclass=DistributionWithoutHelpCommands, **kw File"c:\Python27\Lib\distutils\core.py", line 152, in setup dist.run_commands() File"c:\Python27\Lib\distutils\dist.py", line 953, in run_commands self.run_command(cmd) File"c:\Python27\Lib\distutils\dist.py", line 972, in run_command cmd_obj.run() File"D:\test\sandbox_virtenv\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\command\easy_install.py", line 211, in run self.easy_install(spec, not self.no_deps) File"D:\test\sandbox_virtenv\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\command\easy_install.py", line 422, in easy_install return self.install_item(None, download, tmpdir, deps, True) File"D:\test\sandbox_virtenv\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\command\easy_install.py", line 478, in install_item self.process_distribution(spec, dist, deps) File"D:\test\sandbox_virtenv\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\command\easy_install.py", line 519, in process_distribution [requirement], self.local_index, self.easy_install File"D:\test\sandbox_virtenv\lib\site-packages\setuptools-0.6c11-py2.7.egg\pkg_resources.py", line 563, in resolve dist = best[req.key] = env.best_match(req, self, installer) File"D:\test\sandbox_virtenv\lib\site-packages\setuptools-0.6c11-py2.7.egg\pkg_resources.py", line 799, in best_match return self.obtain(req, installer) # try and download/install File"D:\test\sandbox_virtenv\lib\site-packages\setuptools-0.6c11-py2.7.egg\pkg_resources.py", line 811, in obtain return installer(requirement) File"D:\test\sandbox_virtenv\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\command\easy_install.py", line 434, in easy_install self.local_index File"D:\test\sandbox_virtenv\lib\site-packages\setuptools-0.6c11-py2.7.egg\setuptools\package_index.py", line 475, in fetch_distribution return dist.clone(location=self.download(dist.location, tmpdir)) AttributeError: 'NoneType' object has no attribute 'clone' (sandbox_virtenv) D:\test\py2exe_test> |
现在我可以从python win32api导入,这很令人困惑
1 2 3 4 5 | (sandbox_virtenv) D:\test\py2exe_test>python Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32 Type"help","copyright","credits" or"license" for more information. >>> import win32api >>> |
如果您在这里发现不清楚的地方,请问我。 感谢您的建议。
我想通了,但是过程并不愉快。
PyWin32安装程序存在3个问题:
因此,如果您在64位Windows上运行64位python 2.7或在32位上运行32位,并且您的虚拟环境在c: scratch env1 中,则过程如下所示:
这足以在虚拟环境中运行django-mssql,而无需在虚拟环境外部安装pywin32。
使用最新的virtualenv-1.7.1.2,尝试使用
与此相关的是,在另一台计算机(相同的操作系统,Windows Server 2008 R2)上,我必须创建不带
Windows上的Virtualenv就像一门黑暗的艺术。
这是一个古老的问题,但是最近遇到了这个问题,我想分享一下我所做的工作。我一直在寻找Windows上的python kerberos实现,但发现使用pywin32的kerbeors_sspi。
所有这些都是使用pip安装的,但是pywin32不能使用virtualenv内部的pip安装。
因此,我修补了kerberos_sspi库以使用pypiwin32,它是Glyph和el(扭曲的创建者BTW)打包的轮子。现在,所有这些工作都很棒,即使您要访问COM东西,也必须手动安装pywin32,因为它需要在系统中注册。
这是pypiwin32索引的链接
干杯,
不幸的是,Windows上对64位Python的支持比32位版本差。这不是Python社区的错,而是为64位Windows获取免费编译器的相对困难。
如果安装了64位版本的Python,则还需要使用为64位构建的软件包。某些简单的Python软件包(使用纯Python编写的软件包,不需要外部/ C库)将使用setuptools / easy_install / virtualenv正常安装。但是,许多64位软件包在virtualenv中安装时可能会损坏,并且需要安装程序。
幸运的是,您可以在此处找到流行软件包的64位预编译安装程序。首先尝试那里的包装。该安装程序将针对Python的全局/主要安装,因此不会被virtualenv隔离。但是请注意,这些都是非官方的版本:为方便起见免费提供,因此如果出现问题(或期望获得帮助),请不要起诉提供商。