2

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.

user3109895
  • 31
  • 1
  • 4

3 Answers3

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.

  • I know I'm quite late but I'm having the same issues. Could you elaborate more on how you solved it? I also started a question but no answers so far: http://stackoverflow.com/questions/35261495/py2exe-the-following-modules-appear-to-be-missing – Nerotix Feb 08 '16 at 10:38
  • Not sure about your link below. – Bogdan Tabacaru Dec 01 '16 at 07:43
0

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

sundar nataraj
  • 8,524
  • 2
  • 34
  • 46
  • please Correct me if i am wrong! dont simply downvote – sundar nataraj Jul 03 '14 at 06:13
  • See my comment to the OP on the _question_. The presence or absence of `__init__.py` files won't affect whether or not py2exe includes the wx libraries if they're imported in even a single top level module. – g.d.d.c Jul 03 '14 at 06:15
  • Simply placing an empty __init__.py file did not help. I manually copied the whole folder containing the Frame.py file to the C:\Python27\Lib\site-packages\ before runnning py2exe and it WORKED!!! :) .... People should read the question properly before downvoting. – user3109895 Jul 03 '14 at 06:41
0

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.

user3109895
  • 31
  • 1
  • 4