My .py works, but my .exe doesn't - python

I'm converting a Python file to an .exe using py2exe like so:
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1, 'compressed': True}},
windows = [{'script': "myfile.py"}],
zipfile = None,
)
The .py file works just fine, but when I create the .exe, I get this message:
3 missing Modules
?pywin types imported from -
?win32api imported from platform, win32evtlogutil
?win32com imported from SCRIPT
And when I run the .exe, I get this error:
Traceback (most recent call last):
File "archiveFiles.py", line 83, in
File "archiveFiles.py", line 5, in putItIn
ImportError: No module named 'win32com'
Traceback (most recent call last):
File "archiveFiles.py", line 83, in
putItIn()
File "archiveFiles.py", line 5, in doThatStuff
import win32com.client as win32
ImportError: No module named 'win32com'
Any suggestions?

Related

py2exe: run the compiled .exe, got error: type object 'pandas._libs.tslib._TSObject' has no attribute...__'

I use py2exe to compile python script. The python script runs without any error before compiling.
below is the setup.py
from distutils.core import setup
import py2exe, sys, os
import matplotlib
import numpy
from glob import glob
sys.argv.append('py2exe')
datafiles = [("Microsoft.VC90.CRT", glob(r'C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_99b61f5e8371c1d4\*.*'))]
datafiles.extend(matplotlib.get_py2exe_datafiles())
setup(windows=['Run.py'], data_files= datafiles, options={"py2exe": {"includes": ["matplotlib"]}})
In the run.py, I imported pandas. Pandas is used in a function as below
import pandas
def PossDist(Iterations, AssumptionFolder, ResultFolder, SampledResult):
SampledLoss = pandas.read_csv(SampledResult)
d= pandas.pivot_table(...)
The compile finished successfully without error.
When I run the compiled run.exe, I got error as below.
Traceback (most recent call last):
File "Run.py", line 6, in
File "xlwings__init__.pyc", line 34, in
File "xlwings\main.pyc", line 1727, in
File "xlwings\conversion__init__.pyc", line 3, in
File "pandas__init__.pyc", line 26, in
Main Features
File "pandas_libs__init__.pyc", line 4, in
File "pandas_libs\tslib.pyc", line 12, in
File "pandas_libs\tslib.pyc", line 10, in __load
File "pandas_libs\tslib.pyx", line 1514, in init pandas._libs.tslib
AttributeError: type object 'pandas._libs.tslib._TSObject' has no attribute 'reduce_cython'
Anyone have any clue?
Is there other way to let others run my python script on pc without python installed?
Thanks,

Python - using py2exe with pandas

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?

ImportError: No module named allcontrols with pywinauto and py2exe

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

Python, py2exe, & pyopengl ImportError: No module named win32

When I try to build an exe using py2exe, it builds but when i try to run the exe it throws this error:
Traceback (most recent call last):
File "main.py", line 4, in <module>
File "OpenGL\GL\__init__.pyc", line 3, in <module>
File "OpenGL\GL\VERSION\GL_1_1.pyc", line 10, in <module>
File "OpenGL\platform\__init__.pyc", line 35, in <module>
File "OpenGL\platform\__init__.pyc", line 26, in _load
File "OpenGL\plugins.pyc", line 14, in load
File "OpenGL\plugins.pyc", line 28, in importByName
ImportError: No module named win32
It only does this when I use pyopengl, It builds and runs perfectly with pygame and almost any other library/module I have used.
My setup.py script looks like this:
from distutils.core import setup
import py2exe
setup(console=['main.py'])
I am on Windows 7 64bit
Actually, After another hour or so of searching I found the solution!
For anyone else who has this problem: http://www.py2exe.org/index.cgi/PyOpenGL

Help with py2exe error

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

Categories

Resources