我正在尝试通过执行python setup.py py2exe
从源代码构建一个包
这是setup.py中的一段代码,我想可能是相关的:
if sys.platform == "win32": # For py2exe.
import matplotlib
sys.path.append("C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\redist\\x86\\Microsoft.VC90.CRT")
base_path = ""
data_files = [("Microsoft.VC90.CRT", glob.glob(r"C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*")),
错误,它显示:
*** finding dlls needed ***
error: MSVCP90.dll: No such file or directory
但是我已经安装了"Microsoft Visual Windows2008 Redistributable Package“。我在64位的Windows8上运行32位的C++。我正在尝试构建32位的二进制文件。
也没有这样的文件夹:"C:\Program Files\Microsoft Visual Studio9.0\VC\redist\“。这是我的电脑所包含的内容:
编辑:
在我的C:\驱动器上搜索msvcp90.dll
时,我发现它们安装在奇怪的路径中,如下所示:
发布于 2012-08-28 14:16:01
我建议直接忽略依赖项。将MSVCP90.dll
添加到作为py2exe
选项提供的dll_excludes
列表中。用户必须安装Microsoft Visual C++ 2008 redistributable。举个例子:
setup(
options = {
"py2exe":{
...
"dll_excludes": ["MSVCP90.dll", "HID.DLL", "w9xpopen.exe"],
...
}
},
console = [{'script': 'program.py'}]
)
发布于 2012-08-28 16:12:22
(新答案,因为另一个答案描述了另一个解决方案)
您可以从WinSxS目录中获取文件,并将它们复制到C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT
目录(通常由Visual Studio创建,但您没有Visual Studio)。复制它们以获得以下结构:
+-Microsoft.VC90.CRT
| |
| +-Microsoft.VC90.CRT.manifest
| +-msvcm90.dll
| +-msvcp90.dll
| +-msvcr90.dll
然后,您应该能够运行设置程序(仍然不包括msvcp90.dll
,就像在另一个答案中一样),并且它应该成功地找到Microsoft.VC90.CRT
下的文件,并将它们作为数据文件复制到您的捆绑包中。
有关详细信息,请参阅the py2exe tutorial。
发布于 2012-09-02 07:12:05
我认为这与目录中的空格有关。您应该尝试使用.rstrip()
。例如,放入以下内容:
directory='C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT'
directory=directory.rstrip()
然后,您可以像使用实际路径一样使用变量目录。
这应该使python能够识别之前无法破译的目录。
https://stackoverflow.com/questions/12127869
复制相似问题