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.
Related
I'm using Py2exe and ConfigParser but I have somo problems.
I have installed configparser from pip (pip install configparser) and it works fine. In my code I import the package like this import ConfigParser and when I execute works.
Now I have used py2exe to make a distribution and the output console message is:
The following modules appear to be missing
['Carbon', 'Carbon.Files', '_sysconfigdata', 'backports.configparser']
When I have executed the .exe file, the error message is:
File "GUI.py", line 14, in <module>
File "configparser.pyc", line 12, in <module>
ImportError: No module named backports.configparser
I tried use other kind of import like:
from backports import configparser
or
import backports, backports.configparser
And the results are the same.
My setup.py file:
from distutils.core import setup
import py2exe
opts = {
'py2exe': { 'includes' : ["sys","sip", "time", "decimal"],
'excludes': ['_gtkagg', '_tkagg', '_agg2', '_cairo', '_cocoaagg','_fltkagg', '_gtk', '_gtkcairo'],
'dll_excludes': ['oci.dll','libgdk-win32-2.0-0.dll','libgobject-2.0-0.dll']}
}
data_files=[]
setup(
name='Actualizador',
version='1.0',
package={'./img/*', './campos/*'},
scripts=['GUI.py'],
console=['GUI.py'],
#windows=["GUI.py"],
options=opts,
data_files=data_files,
zipfile=None
)
I can't make my distribution and I can't solve my issue. Any suggestion?
Thank You
I solved the problem :-)
py2exe use the directory build to skip the compilation for some package which are yet compiled. Well, I remove the directory, I add the backports path to system path and I make the distribution again. And magic! That works ...
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 got a windows installer my_script.exe (generated out of my_script.py using py2exe) which is dependent on "PyDes" module,
when I execute my_script.exe it throws an error saying ,
Import error : pyDes module
How to include the pyDes module as a dependency to my_script.py
I am using py2exe to create windows installer.
python setup.py py2exe
Try adding 'includes': ['PyDes'], to the relevant spot in your setup.py file
setup(
# ...
options = {
'includes': ['PyDes'],
},
# ...
)
assuming that PyDes is in your sys.path
N.B. If py2exe hasn't picked up the PyDes dependency, chances are it hasn't picked up anything that PyDes depends on so be prepared for more ImportError's! Just keep adding them to the 'include' until it all works out.
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.