I am new to Python and my project (MyProject) uses PyInstaller to
create standalone executable. I am using the latest PyInstaller trunk
from http://www.pyinstaller.org/browser/trunk?rev=674 and MyProject
works fine with this PyInstaller and Python 2.6.
Now I need to port MyProject to Python 3.0.1. So I have translated
MyProject code to Python 3.0 and to create standalone executable I am
trying to port PyInstaller too to Python 3.0.1.
So I Applied 2to3 tool on it and also made some necessary changes in
the code to support Python 3.
I have also done modification in PyInstaller’s bootloader to support
Python 3.

The different steps like Configuration of my PyInstaller Setup,
Creation of a spec file for my project and Building my project seems
ok.
But when I am running the executable it fails complaining “No module
named tkinter”.

In my project I have kept PyInstaller as Installer.
Below are the outcomes of the different steps:
Step 1. Configuration of my PyInstaller Setup:
C:\Working\Lakshman\MyProject\MyProj-build\Installer>python
Configure.py
I: read old config from config.dat
I: computing EXE_dependencies
I: Finding TCL/TK...
I: found TCL/TK version 8.5
I: testing for Zlib...
I: ... Zlib available
I: Testing for ability to set icons, version resources...
I: ... resource update available
I: Testing for Unicode support...
I: ... Unicode available
I: testing for UPX...
'upx' is not recognized as an internal or external command,
operable program or batch file.
I: ...UPX unavailable
I: computing PYZ dependencies...
I: done generating config.dat

This step generates files config.dat, useTK.py and useUnicode.py
File config.dat:
{'EXE_dependencies': [('python30.dll',
                       'C:\\WINNT\\system32\\python30.dll',
                       'BINARY'),
                      ('MSVCR90.dll',
                       'C:\\WINNT\\system32\\msvcr90.dll',
                       'BINARY'),
                      ('MSVCR90.dll',
                       'C:\\WINNT\\system32\\MSVCR90.dll',
                       'BINARY')],
 'PYZ_dependencies': [('iu',
                       'C:\\Working\\Lakshman\\ MyProject \\MyProj-
build\\Installer\\iu.pyc',
                       'PYMODULE'),
                      ('struct', 'c:\\Python30\\Lib\\struct.pyc',
'PYMODULE'),
                      ('archive',
                       'C:\\Working\\Lakshman\\MyProject\\MyProj-build\
\Installer\\archive.pyc',
                       'PYMODULE')],
 'TCL_root': 'c:\\Python30\\DLLs\\../tcl\\tcl8.5',
 'TK_root': 'c:\\Python30\\DLLs\\../tcl\\tk8.5',
 'hasRsrcUpdate': 1,
 'hasUPX': 0,
 'hasUnicode': 1,
 'python': 'c:\\Python30\\python.exe',
 'pythonDebug': True,
 'pythonVersion': '3.0.1 (r301:69561, Feb 13 2009, 20:04:18) [MSC v.
1500 32 bit (Intel)]',
 'target_platform': 'win32',
 'upx_dir': None,
 'useCrypt': 0,
 'useELFEXE': 1,
 'useZLIB': 1,
 'xtrapath': []}

File useTK.py:
# Generated by Configure.py
# This file is public domain
import os, sys
try:
    basedir = os.environ['_MEIPASS2']
except KeyError:
    basedir = sys.path[0]
tcldir = os.path.join(basedir, '_MEI', 'tcl8.5')
tkdir = os.path.join(basedir, '_MEI', 'tk8.5')
os.environ["TCL_LIBRARY"] = tcldir
os.environ["TK_LIBRARY"] = tkdir
os.putenv("TCL_LIBRARY", tcldir)
os.putenv("TK_LIBRARY", tkdir)

File useUnicode.py:
# Generated by Configure.py
# This file is public domain
import encodings

Step 2. Creation of a spec file for my project
C:\Working\Lakshman\MyProject\MyProj-source\common>python ..\../MyProj-
build\Installer\Makespec.py --debug --tk --onedir --out ..\../MyProj-
image\win32 MyProj.py
wrote ..\../MyProj-image\win32\MyProj.spec
now run Build.py to build the executable

This step generates a spec file is MyProj.spec
File MyProj.spec:
# -*- mode: python -*-
a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'),
os.path.join(HOMEPATH,'support\\useTK.py'), os.path.join
(HOMEPATH,'support\\useUnicode.py'), 'MyProj.py'],
             pathex=['C:\\Working\\Lakshman\\MyProject\\MyProj-source\
\common'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=1,
          name=os.path.join('build\\pyi.win32\\MyProj', 'MyProj.exe'),
          debug=True,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(TkTree(), exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name=os.path.join('dist', 'MyProj'))

Step 3. Building my project
C:\Working\Lakshman\MyProject\MyProj-source\common>python ..\../MyProj-
build\Installer\Bu
ild.py ..\../MyProj-image\win32\MyProj.spec
checking Analysis
building Analysis because outAnalysis0.toc non existent
running Analysis outAnalysis0.toc
Analyzing: ..\../MyProj-build\Installer\support\_mountzlib.py
Analyzing: ..\../MyProj-build\Installer\support\useTK.py
Analyzing: ..\../MyProj-build\Installer\support\useUnicode.py
Analyzing: MyProj.py
Warnings written to ..\../MyProj-image\win32\warnath.txt
checking PYZ
rebuilding outPYZ1.toc because outPYZ1.pyz is missing
building PYZ outPYZ1.toc
checking PKG
rebuilding outPKG3.toc because outPKG3.pkg is missing
building PKG outPKG3.pkg
checking EXE
rebuilding outEXE2.toc because MyProj.exe missing
building EXE from outEXE2.toc
Appending archive to EXE ..\../MyProj-image\win32\build
\pyi.win32\MyProj\MyProj.exe
checking Tree
building because outTree4.toc missing or bad
building Tree outTree4.toc
checking Tree
building because outTree5.toc missing or bad
building Tree outTree5.toc
checking COLLECT
building because outCOLLECT6.toc missing or bad
building COLLECT outCOLLECT6.toc

This creates executable MyProj.exe in C:\Working\Lakshman\MyProject
\MyProj-image\win32\dist\MyProj

When running the executable I get the output below (I have enabled to
print debug messages in iu.py):
C:\Working\Lakshman\MyProject\MyProj-image\win32\dist
\MyProj>MyProj.exe
Found embedded PKG: C:\Working\Lakshman\MyProject\MyProj-image
\win32\dist\MyProj\MyProj.exe
Extracting binaries
C:\Working\Lakshman\MyProject\MyProj-image\win32\dist\MyProj
\python30.dll
Manipulating evironment
PYTHONPATH=C:/Working/Lakshman/MyProject/MyProj-image/win32/dist/
MyProj
importing modules from CArchive
extracted iu
extracted struct
extracted archive
Installing import hooks
outPYZ1.pyz
Running scripts
importHook(os, __main__, locals, None, 0)
 importHook trying os in None
importHook done with os __main__ None (case 2)
importHook(sys, __main__, locals, None, 0)
 importHook trying sys in None
importHook done with sys __main__ None (case 2)
importHook(encodings, __main__, locals, None, 0)
 importHook trying encodings in None
importHook done with encodings __main__ None (case 2)
importHook(tkinter, __main__, locals, ('*',), 0)
 importHook trying tkinter in None
trying tkinter None tkinter
doimport(tkinter, None, tkinter)
importHook(imp, archive, locals, None, 0)
 importHook trying imp in None
importHook done with imp archive None (case 2)
importHook(imp, archive, locals, None, 0)
 importHook trying imp in None
importHook done with imp archive None (case 2)
..found None when looking for tkinter
Traceback (most recent call last):
  File "<string>", line 62, in <module>
  File "C:\working\lakshman\MyProject\MyProj-build\Installer\iu.py",
line 454, in impo
rtHook
importHook(io, None, locals, ['__doc__'], 0)
 importHook trying io in None
importHook done with io None ['__doc__'] (case 3)
importHook(encodings.utf_8, None, locals, ['*'], 0)
 importHook trying encodings in None
 importHook trying utf_8 in encodings
importHook done with encodings.utf_8 None ['*'] (case 3)
    raise ImportError("No module named %s" % fqname)
ImportError: No module named tkinter
RC: -1 from MyProj
OK.


I have tried the same also for Linux and end-up with the same error.
I am unable to find what is going wrong here.
Any help will be greatly appreciated.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To post to this group, send email to PyInstaller@googlegroups.com
To unsubscribe from this group, send email to 
pyinstaller+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/PyInstaller?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to