In Python environment all works, but program generated by py2exe returns
this error.
Setup py:
#! /usr/bin/python
# -*- coding: utf-8 -*-
from distutils.core import setup
import py2exe
#setup(console=["victor.py"])
setup(
options = {
"py2exe": {
"compressed": 1,
"optimize": 2,
"packages": ["Pmw"],
"excludes": [],
}
},
name="Docházky Splirec",
version="1.0 B1",
description="Převod docházky firmy Splirec z XLS do Amzdy",
author="C.A.C spol. s r. o.",
author_email="x...@uuu.aa",
windows=[{"script": "frmMain.py"}],
)
Dne 4.3.2010 16:34, Massa, Harald Armin napsal(a):
> Setup py:
>
> #! /usr/bin/python
> # -*- coding: utf-8 -*-
>
> Reason:
>
> distutils does not pickup your xlrd import.
>
> Most likely course:
>
> - you import from xlrd, but do not import xlrd
>
> that is
>
> from xlrd import Sheet, Row...
>
> I recommend to put an "import xlrd" in the main module of your
> application.
^^^I've tried this, but without positive effect, error stays same:
"""
Traceback (most recent call last):
File "frmMain.py", line 13, in <module>
File "clsConvert.pyo", line 4, in <module>
ImportError: No module named xlrd
Traceback (most recent call last):
File "frmMain.py", line 13, in <module>
ImportError: No module named xlrd
"""
Sources (parts of) are at the bottom of mail. Does anybody using xlrd
and py2exe together? I'm user of Python 2.6.
*Setup.py*:
#! /usr/bin/python
# -*- coding: utf-8 -*-
from distutils.core import setup
import py2exe
setup(
options = {
"py2exe": {
"compressed": 1,
"optimize": 2,
"packages": ["Pmw"],
"excludes": [],
}
},
name="Docházky Splirec",
version="1.0 B1",
description="Převod docházky firmy Splirec z XLS do Amzdy",
author="C.A.C spol. s r. o.",
author_email="m.ols...@amzdy.cz",
windows=[{"script": "frmMain.py"}],
)
*Begin of frmMain.py*
#! /usr/bin/python
# -*- coding: utf-8 -*-
#system imports
from Tkinter import *
import tkMessageBox, tkFileDialog
import os, fnmatch
from time import localtime, strftime
#other imports
import Pmw
import xlrd
from clsConvert import *
class frmSplirec:
def __init__(self,master,ar,xy,flex):
*Begin of clsConvert:*
#! /usr/bin/python
# -*- coding: utf-8 -*-
import xlrd
from xlrd import open_workbook
import os
import re
class clsConvertAll:
> import xlrd
> from xlrd import open_workbook
As Harald said, don't do that. Delete the
"from xlrd import open_workbook"
and where ever in that module you use
"something = open_workbook(..."
change it to
"something = xlrd.open_workbook(..."
> I have improved my success with py2exe by 2000% with totally deleting
> the build-directory between 2 consecutive py2exe-builds
Agreed; for some unknown reason py2exe seems to have trouble working out
what's out of date and what's not. Run your build twice; still using old
code -- delete build directory, run build again, it uses latest code.
Mystery.
Hello,
i've tried it, but result vas the same.
In second i've tried merge both, of my program, classes into one file,
with same result:
"""
Traceback (most recent call last):
File "frmMain.py", line 13, in <module>
ImportError: No module named xlrd
"""
I've tried to reduce setup py tu minimal version:
#! /usr/bin/python
# -*- coding: utf-8 -*-
from distutils.core import setup
import py2exe
setup(windows=["frmMain.py"])
And rewrote initial imports:
#system imports
from Tkinter import *
import tkMessageBox, tkFileDialog
import os, fnmatch
from time import localtime, strftime
#other imports
import Pmw
import xlrd
#from xlrd import *
Same result. Is really possible make distribution exe with "xlrd"?
Thank You All,
MaReK
Yes really possible. A couple of years ago I was regularly creating over
10 exes from the one setup.py file ... each needed xlrd or xlwt or both.
No problems. No party tricks needed. Just avoided "from <module> import
<thing>".
Have you followed Harald's advice to (1) """put some "xref":1
in your py2exe-options, that shows you what is referencing what."""
(2) delete the build directory first?
Try this:
Make a little app that does this:
#! /usr/bin/python
# -*- coding: utf-8 -*-
import xlrd
print xlrd.__file__
and run it using python in the same directory where you run the py2exe
setup. What does it print? Try to run it as a py2exe console app. What
happens?
Dne 5.3.2010 16:02, John Machin napsal(a):
>
> #! /usr/bin/python
> # -*- coding: utf-8 -*-
> import xlrd
> print xlrd.__file__
>
> and run it using python in the same directory where you run the py2exe
> setup. What does it print? Try to run it as a py2exe console app. What
> happens?
>
thank You, that helped.
I've used to install xlrd and xlwt from "*.exe" files, and there were
bad pathes. After installed with setup.py from sources package all works OK.
I'd like to know why program worked after start from console
("c:\python26\python.exe frmMain.py"), but after "compilation" doesn't.
Thanks for help and patience.
MaReK