'modules appear to be missing' - py2exe

心已入冬 提交于 2019-12-20 05:14:08

问题


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.

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.

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"])

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?

Thanks in advance.


回答1:


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>)

This way I do no need to polute the ...\site_packages\ folder.




回答2:


Here is what finally worked for me. Manually copying the folder containing the files which your .py(to be converted to .exe) file imports, before running py2exe, to Python27\Lib\site-packages\ fixes such problems I guess.




回答3:


you need to place '__init__.py' to every module your using in your project. since init.py tell to your py2exe convertor that there is a python module here.

Since i have faced the same issue Few days back. with zope.interface and mp_tools i placed empty __init__.py worked fine for me



来源:https://stackoverflow.com/questions/24524483/modules-appear-to-be-missing-py2exe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!