“模块似乎丢失" - py2exe [英] 'modules appear to be missing' - py2exe
问题描述
我正在使用 py2exe-0.6.9.win32-py2.7.exe 并将 .py 文件转换为 .exe.问题是它不会打开,因为当我尝试打开 .exe 文件时,它会说无法导入框架".'Frame' 是另一个 .py 文件,我在其中编写了一些代码.
I am using py2exe-0.6.9.win32-py2.7.exe and converted a .py file to .exe. The problem is that it won't open as it says something like 'unable to import Frame' when I try to open the .exe file. 'Frame' is another .py file which I wrote some code in.
此外,当我打开另一个 .exe(从 .py 转换而来)文件时,该文件不会导入我制作的某些 .py 文件,然后它打开时没有任何问题.
Also, when I open another .exe(converted from .py) file which does not import some .py file which I made, then it opens without any problem.
这是我的 setup.py 文件.
Here is my setup.py file.
from distutils.core import setup
import py2exe
from glob import glob
import sys
import os
sys.path.append("C:\\Users\\USER\\Desktop\\Microsoft.VC90.CRT")
print os.path.isdir("C:\\Users\\USER\\Desktop\\Microsoft.VC90.CRT")
data_files = [("Microsoft.VC90.CRT",glob(r'C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\*.*'))]
setup(data_files="",console=["C:\\3d-Model\\bin\\Application.py"])
编辑:我明白了这个问题.仅存在于 C:\Python27\Lib\site-packages\ 中的模块由 .exe 文件导入.现在的问题是,在运行 py2exe 之前,我是否必须将 .exe 文件试图导入的每个模块都复制到 C:\Python27\Lib\site-packages\ 或者还有其他更简单的方法吗?
EDIT: I understood the problem. the modules present only in C:\Python27\Lib\site-packages\ gets imported by the .exe file. The question now is do I have to copy every module the .exe file is trying to import to C:\Python27\Lib\site-packages\ before running py2exe or is there any other easier way?
提前致谢.
推荐答案
我所做的是更新 'setup.py'
文件以包含缺少模块的路径,使用
What I did is I updated the 'setup.py'
file to contain the paths to the missing modules, using
import sys
sys.path.insert(0, <path_to_missing_modules>)
这样我就不需要污染 ...\site_packages\
文件夹.
This way I do no need to polute the ...\site_packages\
folder.
这篇关于“模块似乎丢失" - py2exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!