为什么py2exe停在"运行"?

时间:2016-05-24 06:46:34

标签: python windows anaconda py2exe

我想在Windows 7和Anaconda下使用py2exe从.py脚本创建一个.exe文件。

所以我创建了一个setup.py文件:

from distutils.core import setup 
import py2exe 

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

现在我在Windows-CMD中导航到" mouseMove.py"和" setup.py"存在并开始:

python setup.py py2exe

在cmd窗口中,它写了#34;运行py2exe"它仍处于这种状态,没有其他事情发生。

有谁知道问题出在哪里?

mouseMove.py的内容:

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

1 个答案:

答案 0 :(得分:0)

尝试以下setup.py文件。我希望它的运作。

 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\*.*'))]

)