1

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()
jgritty
  • 11,660
  • 3
  • 38
  • 60
kyi
  • 43
  • 1
  • 10
  • Can you show us mouseMove.py? – jgritty May 24 '16 at 06:48
  • Of course. But i also tried it with a simple "hello world"-example and there was the same behaviour: import pyautogui import sys xCoords = sys.argv[1] yCoords = sys.argv[2] pyautogui.moveTo(xCoords, yCoords) pyautogui.click() – kyi May 24 '16 at 06:48
  • This actually worked for me. Are you able to successfully `import py2exe` and `import pyautogui` from a python prompt? – jgritty May 24 '16 at 08:14
  • Of course, you can't actually make it work, because the xCoords and yCoords are of type string, and moveTo expects integers. – jgritty May 24 '16 at 08:16
  • Okay this was a bug, but it's not the problem, like i said, i also tried it with a simple "hello-world"-example. I can import the packages as well. The programm is running as .py file. Maybe the problem has to do with anaconda? – kyi May 24 '16 at 08:56
  • Maybe, I never use that. – jgritty May 24 '16 at 17:44

1 Answers1

0

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

)
user3080885
  • 63
  • 1
  • 1
  • 6