Why does py2exe stop at “running”?

2019-07-26 16:26发布

问题:

I want to create an .exe file from a .py script using py2exe under Windows 7 and Anaconda.

So I created a setup.py file:

from distutils.core import setup 
import py2exe 

setup(console=['mouseMove.py'], options = {'py2exe': {'packages': ['pyautogui']}})

Now I navigate in the Windows-CMD to the directory which "mouseMove.py" and "setup.py" exists and start:

python setup.py py2exe

In the cmd window its written "running py2exe" and it remains in this state, nothing else happens.

Does anyone know where the problem is?

Contents of mouseMove.py:

import pyautogui 
import sys 
xCoords = sys.argv[1] 
yCoords = sys.argv[2] 
pyautogui.moveTo(xCoords, yCoords) 
pyautogui.click()

回答1:

Try the below setup.py file. I hope its working.

 from distutils.core import setup
import py2exe
from distutils.filelist import findall
import os
import matplotlib
from glob import glob
matplotlibdatadir = matplotlib.get_data_path()
matplotlibdata = findall(matplotlibdatadir)
matplotlibdata_files = []
for f in matplotlibdata:
    dirname = os.path.join('matplotlibdata', f[len(matplotlibdatadir)+1:])
    matplotlibdata_files.append((os.path.split(dirname)[0], [f]))


setup(
    console=['resolution_finder.py'],
    options={
             'py2exe': {
                        'includes': ["sip", "PyQt4.QtGui","scipy.special._ufuncs_cxx"],
                        'packages' : ['matplotlib', 'pytz'],
                        'excludes': ['_gtkagg', '_tkagg'],
                        "dll_excludes": ["MSVCP90.dll"]   
                       }
            },


    data_files=matplotlib.get_py2exe_datafiles()
    #data_files=[('matplotlib.get_py2exe_datafiles()', [("Microsoft.VC120.CRT", glob(r'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\x86\Microsoft.VC120.CRT\*.*'))])]

    #data_files = [("Microsoft.VC120.CRT", glob(r'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\x86\Microsoft.VC120.CRT\*.*'))]

)