I want to generate an .exe file from a python script which includes the pywinauto module.
It builds fine, however when running the resulting dist\pywinauto_sample.exe, I get this error:
Traceback (most recent call last):
File "pywinauto_sample.py", line 2, in <module>
from pywinauto import application
File "pywinauto\application.pyc", line 68, in <module>
File "pywinauto\controlactions.pyc", line 45, in <module>
File "pywinauto\tests\__init__.pyc", line 128, in <module>
File "pywinauto\tests\__init__.pyc", line 114, in __init_tests
ImportError: No module named allcontrols
Here's my pywinauto_sample.py:
import pywinauto
from pywinauto import application
app = pywinauto.application.Application()
And here's my setup.py:
from distutils.core import setup
import py2exe
setup(console=['pywinauto_sample.py'])
I compile the program with:
python setup.py py2exe
Add this to your setup.py:
from distutils.core import setup
import py2exe
setup(
console=
[
'pywinauto_sample.py'
],
options=
{
"py2exe":
{
"includes":
[
"pywinauto.tests.truncation",
"pywinauto.tests.translation",
"pywinauto.tests.repeatedhotkey",
"pywinauto.tests.overlapping",
"pywinauto.tests.missingextrastring",
"pywinauto.tests.missalignment",
"pywinauto.tests.miscvalues",
"pywinauto.tests.leadtrailspaces",
"pywinauto.tests.comparetoreffont",
"pywinauto.tests.comboboxdroppedheight",
"pywinauto.tests.asianhotkey",
"pywinauto.tests.allcontrols",
]
}
}
)
Source: http://permalink.gmane.org/gmane.comp.python.py2exe/4663
Related
I have a python 2.7 script that uses zmq and am trying to build a windows executable for it using py2exe. I get the following error:
Traceback (most recent call last):
File "console.py", line 4, in <module>
File "zmq\__init__.pyc", line 34, in <module>
File "zmq\backend\__init__.pyc", line 40, in <module>
File "zmq\backend\__init__.pyc", line 27, in <module>
File "zmq\backend\select.pyc", line 26, in select_backend
ImportError: No module named cython
I have tried py2exe --includes option, including cython and zmq with no success. I have also tried running the script with -O option and copying the resulting .pyo files to my dist directory. What am I missing?
This did the trick in my setup.py
import zmq.libzmq
setup(\
version='0.0.1',
options = {'py2exe' : {
'includes': [ 'zmq.backend.cython'],
"optimize": 2,
'packages': 'encodings'
},
},
data_files=[
('lib', (zmq.libzmq.__file__,))
],
console=['app.py'],
scripts = [ "app.py","file1.py","file2.py","file3.cfg"],
zipfile = 'None',
)
Hope it helps someone.
Problem
For some reason when importing the seaborn package, and making an executable (.exe) will give following ImportError. How to troubleshoot this?
Traceback (most recent call last):
File "C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\cx_Fr
eeze\initscripts\__startup__.py", line 12, in <module>
__import__(name + "__init__")
File "C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\cx_Fr
eeze\initscripts\Console.py", line 21, in <module>
scriptModule = __import__(moduleName)
File "GUI.py", line 22, in <module>
import seaborn as sns
File "C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\seabo
rn\__init__.py", line 9, in <module>
from .linearmodels import *
File "C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\seabo
rn\linearmodels.py", line 8, in <module>
from scipy.spatial import distance
File "C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\scipy
\spatial\__init__.py", line 93, in <module>
from .ckdtree import *
ImportError: No module named 'scipy.spatial.ckdtree'
Additional Information
Setup
Windows 7 Enterprise 64-bit
WinPython-64bit-3.5.2.3Qt5 (Python 3.5.2 64-bit)
cx_Freeze 5.0
scipy 0.18.1
Renamed the finder.IncludePackage("scipy.lib") in the cx_Freeze/hooks.py to finder.IncludePackage("scipy._lib") as instructed in the answer of the SO Question "Cx_freeze ImportError no module named scipy"
setup.py:
import os
import sys
from cx_Freeze import setup, Executable
os.environ['TCL_LIBRARY'] = r"C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\tcl\tcl8.6"
os.environ['TK_LIBRARY'] = r"C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\tcl\tk8.6"
base = None
options = {
'build_exe': {
'excludes': ['gtk', 'PyQt4', 'Tkinter'],
'packages': ['scipy'],
'includes': ['scipy.spatial.ckdtree'],
}
}
executables = [
Executable('GUI.py', base=base)
]
setup(name='GUI',
version='0.1',
description='GUI test',
executables=executables,
options=options
)
Try renaming cKDTree.cp35-win_amd64.pyd to ckdtree.cp35-win_amd64.pyd. This works for my case.
The file shoudld be under your build path, such as build\exe.win-amd64-3.5\scipy\spatial\.
I'm trying to create an *.exe file from my Python code.
This is my setup.py file:
from distutils.core import setup
import py2exe
import matplotlib
import sys
sys.setrecursionlimit(5000)
setup(
options={
'py2exe':
{
'includes': ['lxml.etree', 'lxml._elementpath', 'gzip','pandas'],
}
},
data_files=matplotlib.get_py2exe_datafiles(),
console=['test_zone_A_main.py'])
The code works fine on my machine, but when I'm running the exe on different machine , I'm getting the following error:
C:\Program Files (x86)\company\Campaign_Analyze>"C:\Program Files (x86)\sintec\Ca
mpaign_Analyze\dist\test_zone_A_main.exe"
Traceback (most recent call last):
File "test_zone_A_main.py", line 9, in <module>
File "calcs_performence.pyc", line 11, in <module>
File "test_config_cs.pyc", line 11, in <module>
File "pandas\__init__.pyc", line 13, in <module>
ImportError: C extension: DLL load failed: The specified module could not be found. not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
Any ideas?
I want to create an exe file using Py2exe module. The problem is that the exe file says that there is not os module. I've put it into includes in setup.py file so it should work.
Here is the error after run main.exe created by Py2Exe
import linecache
ImportError: No module named linecache
Traceback (most recent call last):
File "main.py", line 3, in <module>
ImportError: No module named os
And here is my setup.py:
from distutils.core import setup
import py2exe
setup(console=["main.py"],options = {
"py2exe":{
"includes": ["os","linecache"]
}
},)
The problem is that if you want to import packages, you should use the option packages and not includes. The first one imports libraries, the second modules.py.This should work now:
from distutils.core import setup
import py2exe
setup(console=["main.py"],
options = {
"py2exe":{
"packages": ["os","linecache"]
}
})
I'm trying to compile to an exe my script of python, but I'm getting an error that I'm not know how to resolve...
my script include this libraries
import pyHook
import pythoncom
import time
import win32com.client
and the py2exe script is
from distutils.core import setup
import py2exe
import sys
sys.argv.append('py2exe')
setup(
options = {'py2exe': dict(bundle_files=1, optimize=1)},
console = ["login.macro.py"],
zipfile = None,
)
and I'm getting the error
Traceback (most recent call last):
File "login.macro.py", line 4, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "win32com\__init__.pyo", line 5, in <module>
File "zipextimporter.pyo", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading win32api.pyd
How can I solve it?
I've just compiled another script and went everything ok
Try bundle_files=3 :
http://mail.python.org/pipermail/python-win32/2009-June/009227.html