Help with py2exe error - python

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

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,

Exe file says - cannot import name chardet

I'm trying to make an exe file using py2exe. The problem is that when I try to run created exe file, it returns that it cannot import name chardet.
Traceback (most recent call last):
File "orsr_parser.py", line 10, in <module>
File "requests\__init__.pyc", line 58, in <module>
File "requests\utils.pyc", line 26, in <module>
File "requests\compat.pyc", line 7, in <module>
ImportError: cannot import name chardet
I use requests module in one of the py files in the program.
Setup.py:
from distutils.core import setup
import py2exe
packages = ['requests']
setup(console=['my_script.py'])
Do you know where could be the problem? Is there something with setup.py file?
EDIT: There is only one answer for this problem: Stackoverflow answer, but I probably don't get it. There is no directory called requests in my project.

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

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?

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

Categories

Resources