I am trying to make a single executable out of my application that uses matplotlib using Python 2.7 and py2exe. So, I have this standard routine:
from distutils.core import setup
import zmq.libzmq
import py2exe
import glob
import matplotlib
import shutil
ico_file = "C:/Users/MyPC/Documents/newIcon.ico"
setup( windows = [{
"script":"myApp.py",
"icon_resources": [(1, ico_file)]
}],
options={
'py2exe': {
'includes':['zmq.backend.cython',
'scipy.special._ufuncs_cxx',
'scipy.linalg.cython_blas',
'scipy.linalg.cython_lapack',
'scipy.sparse.csgraph._validation'],
'excludes':['zmq.libzmq'],
'dll_excludes':['libzmq.pyd'],
'bundle_files': 2,
'compressed': True
}
},
zipfile=None,
data_files=[ ('lib', (zmq.libzmq.__file__,), ico_file) ] + matplotlib.get_py2exe_datafiles()
)
Problem Definition The created file, myApp.exe, does not run after double clicking on it (or calling from cmd). So, I used Dependency walker and I can see that zlip.pyd is missing:
LoadLibraryA("c:\users\mypc\documents\myapp\bin\dist\zlib.pyd") returned NULL. Error: The specified module could not be found (126).
Now if I change 'bundle_files': 3, I have myApp.exe running just fine, though I get a cluttered distribution directory. Any ideas about what is going wrong here?
Related
i wrote a BOT for a webgame, works perfectly when i run it with IDLE, firefox launches and does the job. But after compiling with Py2exe firefox doesn't launch anymore...Any ideas ?
PS : Firefox 45.0.2 , Selenium 2.53
Hum finally i solved it, was my mistake, i was copying th wedriver.xpi and webdriver_prefs.json in the wrong directory...
So you need to compile it without making a Zipfile (or won't work) and copy the 2 files in the good directory :
from : C:\Python27\Lib\site-packages\selenium\webdriver\firefox
to : /dist/selenium/webdriver/firefox
Setup.py example:
from distutils.core import setup
import py2exe
setup(
name='Web BOT',
version='1.0',
description='BOT',
author='Author',
author_email='mymail#mail.com',
url='',
windows = [{
"script":"Myscript.py",
"icon_resources": [(1, "myicon.ico")],
}],
options={
'py2exe':
{
'skip_archive': True,
'optimize': 2,
}
}
)
And then everything works fine !
To use pandas lib, I make a simple python program.
It works well when I run the *.py file. After I pack all the files into a exe with py2exe, I double click the exe to run it, then I get a message in the command line window:
Please install lxml if you want to use 'options' class.
Does it mean lxml lib is not packed into my exe correctly? Anyone know how to solve the problem?
My setup.py is:
from distutils.core import setup
import py2exe
setup(console=['app.py'],
options={
'py2exe': {
'includes': ['lxml.etree',
'lxml._elementpath',
'numexpr'],
}
}
)
Then the new problem comes:numexpr not found. cannot use engine = numexpr for query/eval if numexpr is not installed.
I'm compiling a python script to .exe via py2exe. I originally started compiling it and the entire program ran fine aside from the Word document creation.
My logfile would give me: ERROR: Could not close or save Word Document 'docName.docx' :, so where I am supposed to be supplied an error message - I am not.
I started to think it could do with the missing modules in py2exe, reported as:
The following modules appear to be missing
['ICCProfile', '_imaging_gif', '_scproxy', '_sysconfigdata']
And then I noticed many people didn't care too much about these errors.
I looked in the docx package, located in C:\Python27\Lib\site-packages\docx-0.2.4-py2.7.egg\, as installed by easy_install, and saw this docx-templates folder, which I am certain was not imported, so I wrote my setup.py referencing the docx-template I put in my build folder manually:
from distutils.core import setup
from glob import glob
import os
import py2exe
#templatePath = 'C:/Python27/Lib/site-packages/docx-0.2.4-py2.7.egg/docx-template'
setup(
console=['xmlpolicydocx-0.4.py'],
options={
'py2exe':
{
'includes': ['docx', 'PIL', 'lxml.etree', 'lxml._elementpath', 'gzip']
}
},
packages=[
'docx-template'
],
package_data={
'docx-template': [
'_rels/*',
'docProps/*',
'word/theme/*.xml',
'word/*.xml'
],
},
)
Yet I still have no luck in getting docx to work when compiled via py2exe. Any suggestions or methods of debugging I can take to take another look at solving this problem?
I'm trying to use py2exe to convert my .pyw to executable file, and
encountered this error - "ImportError: No module named matplotlib.python-dateutil"
I've installed dateutil before trying to convert this .pyw to .exe,
and .pyw file itself worked fine and produced the expected output,
but I didn't manage to get the .exe file.
I also have tried put a copy of python-dateutil inside matplotlib folder but still did not solve the problem.
I'm using Python 2.7 and python-dateutil 2.2.
This is my setup.pyw. copied from (http://www.py2exe.org/index.cgi/MatPlotLib)
from distutils.core import setup
import py2exe
import matplotlib
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(
windows = ['graph.pyw'],
options = {
'py2exe': {
'packages' : ['matplotlib', 'pytz'],
}
},
#data_files = matplotlibdata_files
data_files = matplotlib.get_py2exe_datafiles() )
Appreciate feedback and ideas..thank you very much in advance
I think you need to put matplotlib.python-dateutil in the packages list:
'packages' : ['matplotlib', 'matplotlib.python-dateutil', 'pytz'],
When this hasn't fixed similar hassles for me, I've sometimes found that you need to wildcard submodules:
'packages' : ['matplotlib', 'matplotlib.python-dateutil.*', 'pytz'],
YMMV on that one.
I am trying to convert a py file to an exe.
Here is the code for my setupfile
from distutils.core import setup
import py2exe
setup(console=["mycode.py"])
When I use cmd, it says:
Import Error: No module named easygui
How do I let py2exe know about the easygui? As well as the numpy and mathplotlib (all are used in mycode.py)
First, use pyinstaller. It is newer and better (though I have used py2exe until switching to pyinstaller) And it seems to have much better recipes for finding your included libs.
But for py2exe, you will need to expand that setup.py a bit more to tell it what to include (since they are probably hidden imports)
setup(
console=["mycode.py"],
options={
"py2exe": {
"includes": ["easygui"],
"bundle_files": 1
},
},
zipfile = None,
)
If this fails to build, then easygui is not in your PYTHONPATH properly. Make sure you are not doing something special in your script to add a pythonpath, which would not be visible to py2exe.
You may need to do a little more work with this file for numpy and matplotlib. See this wiki for help
Relative to the issue of the specific dll's mentioned, I had similar issues but fixed those problems by specifically excluding those in the setup lie so:
setup(
console=['DET14.py'],
options={
'py2exe': {
'packages' : ['matplotlib', 'pytz'],
'dll_excludes':['MSVCP90.DLL',
'libgdk-win32-2.0-0.dll',
'libgobject-2.0-0.dll',
'libgdk_pixbuf-2.0-0.dll'],
'includes':['scipy.sparse.csgraph._validation',
'scipy.special._ufuncs_cxx']
}
},
data_files=matplotlib.get_py2exe_datafiles()
)`
I would say try adding that exclude to your setup statement.