Python Forum
Problem py2exe - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Problem py2exe (/thread-885.html)

Pages: 1 2


Problem py2exe - andrea1980345 - Nov-12-2016

Hello guys, i have a problem with py2exe. When i do this comand i got an error for modules, this

Error:
C:\Users\Game\AppData\Local\Programs\Python\Python35>python setup.py py2exe running py2exe   1 missing Modules   ------------------ ? _cpyHook                            imported from pyHook.cpyHook Building 'dist\Test2.exe'. error: [Errno 2] No such file or directory: 'C:\\Users\\Game\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\py2exe\\run_w-py3.5-win-amd64.exe'
I try to move the file cpyHook to the py2exe folder but nothing.. Hope you guys can help me!  Tongue


RE: Problem py2exe - metulburr - Nov-12-2016

can you show us the setup file?

if your not importing these modules you can exclude them
    setup(
    options={'py2exe':{'excludes':['Image','PIL._imagingagg','PyQt4',
    'PyQt5','_abcoll','_imaging_gif','_util','cffi','lxml','openpyxl.tests',
    'readline','tkinter']}},
     )



RE: Problem py2exe - andrea1980345 - Nov-12-2016

Thanks for reply, here the setup file
from distutils.core import setup
import py2exe
setup(windows=["Test2.py"])



RE: Problem py2exe - metulburr - Nov-12-2016

can you show the content of Test2.py?


RE: Problem py2exe - andrea1980345 - Nov-12-2016

Not really, im working at this one since a lot, need to end it and then i can post :) hope you understand. By tha way is working, i test it, 0 problem. And all the import are ok. There are the import 
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
import pythoncom, pyHook, logging, time, win32console, win32gui, os, smtplib, shutil, win32api, win32con, threading




RE: Problem py2exe - snippsat - Nov-12-2016

Here my script for py2exe,you can include(includes, excludes, packages).
from distutils.core import setup
import py2exe
import sys

def py2_exe(file_in, ico=None):
    if ico == None:
        pass
    else:
        dest_ico = ico.split('.')[0]
    if len(sys.argv) == 1:
        sys.argv.append('py2exe')

    # Py2exe finds most module,here you can include,exclude moduls
    includes = []
    excludes = []
    packages = []
    dll_excludes = []

    # Bundle_files : 3 most stable | bundle_files : 1 create 1 big exe
    setup(options =\
    {'py2exe': {'compressed': 1,
                'optimize': 2,
                'ascii': 0,
                'bundle_files': 2,
                'includes': includes,
                'excludes': excludes,
                'packages': packages,
                'dll_excludes': dll_excludes,}},
                 zipfile = None, #None or "lib\library.zip"

    # Can use console(Command line) or windows(GUI)
    console = [{
              'script': file_in,
              #--| Uncomment for ico
              ##'icon_resources' : [(1, ico)],
              ##'dest_base' : dest_ico
                   }])

if __name__ == '__main__':
    #--| The .py file you want to make exe of
    file_in = 'your.py'
    #--| Ico in same folder as .py
    #ico = 'your.ico'
    py2_exe(file_in)
Could be a tips.
Quote:@Whatevs To compile it (at least with py2exe) copy the _cpyHook.pyd and cpyHook.py
files into the "...Lib\site-packages" directory and it worked for me



RE: Problem py2exe - andrea1980345 - Nov-12-2016

I copy the _cpyHook.pyd and cpyHook.py in site-packages and now i got this error
[size=x-large]
Error:
C:\Users\Game\AppData\Local\Programs\Python\Python35>python setup.py py2exe[/size] running py2exe Building 'dist\Test2.exe'. error: [Errno 2] No such file or directory: 'C:\\Users\\Game\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\py2exe\\run_w-py3.5-win-amd64.exe'



RE: Problem py2exe - metulburr - Nov-12-2016

Quote:run_w-py3.5-win-amd64.ex

is your python 32 bit?


RE: Problem py2exe - andrea1980345 - Nov-12-2016

Nope, mine is 64


RE: Problem py2exe - metulburr - Nov-12-2016

Though there is success in 64 bit. I have had fewer problems using 32 bit. I purposely use 32 bit when i want to make an exe for this reason alone. But that would require a separate python install, py2exe, and any other 3rd party lib you installed. Im not saying this will fix the problem. Im not sure...i have never seen that error before. But its an option to try.