unsolved dependency on tcl, when using matplotlib and pyqt4

321 views
Skip to first unread message

Spinel

unread,
Jan 30, 2012, 11:48:04 AM1/30/12
to pyins...@googlegroups.com
Hi,

First of all let me thank the developers of this great project for sharing it with everybody.

I'm writing to this list because I found a little issue. I'm running a program with lots of dependencies and all of them work except one on tcl which actually shouldn't be there since matplotlib uses the pyqt4 backend...

Here are the steps to reproduce the problem:

I installed pyinstaller1.5.1 (python Configure.py) in a Windows 7 machine, and then ran:
python Makespec.py path/to/main.py
python Build.py path/to/main.spec

but when I run main.exe on the same system without having python2.7 installed, it returns:
<<
Traceback (most recent call last):
  File "<string>", line 259, in <module>
  File "<string>", line 254, in main
  File "<string>", line 45, in __init__
  File "main\build\pyi.win32\main\
outPYZ1.pyz/matplotlib.pyplot", line 343, in f
igure
  File "main\build\pyi.win32\main\outPYZ1.pyz/matplotlib.backends.backend_tkagg"
, line 80, in new_figure_manager
  File "main\build\pyi.win32\main\outPYZ1.pyz/Tkinter", line 1685, in __init__
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
    C:/Users/user/AppData/Local/Temp/lib/tcl8.5 C:/pyinstaller-1.5.1/main/lib/tc
l8.5 C:/pyinstaller-1.5.1/lib/tcl8.5 C:/pyinstaller-1.5.1/main/library C:/pyinst
aller-1.5.1/library C:/pyinstaller-1.5.1/tcl8.5.2/library C:/tcl8.5.2/library

This probably means that Tcl wasn't installed properly.
>>

(installing python2.7, which includes tcl, solves the issue but I would like to run it on a system without neither python2.7 nor tcl installed)

I'm including matplotlib in main.py as follows:
<<
import sys

from PyQt4.QtCore import QString
from PyQt4.QtGui import QApplication,QMainWindow,QFileDialog
from ui_mainwindow import Ui_MainWindow

import numpy

import matplotlib
matplotlib.use("Qt4Agg")
from matplotlib import pyplot
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.ticker import FuncFormatter

import win32com.client as win32
import pythoncom
import source
>>

Any ideas on how to solve this? Did anybody come across this before?

Thanks in advance

Hartmut Goebel

unread,
Feb 2, 2012, 11:28:33 AM2/2/12
to pyins...@googlegroups.com
Am 30.01.2012 17:48, schrieb Spinel:
> Any ideas on how to solve this? Did anybody come across this before?

When using PyInstaller 1.5.1 you need to create your specfile with the
--tk switch. This will add some magic to youe spec-file.

Or try the current development version which does no longer require this
magic and no longer requires the --tk switch.

In the later case, please report success or failure and this part of the
code is only a few weeks old.

--
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP, CSSLP

Goebel Consult
Spezialist für IT-Sicherheit in komplexen Umgebungen
http://www.goebel-consult.de

Monatliche Kolumne: http://www.cissp-gefluester.de/
Goebel Consult ist Mitglied bei http://www.7-it.de


spinel

unread,
Feb 5, 2012, 5:32:59 PM2/5/12
to PyInstaller
Thanks a lot for the answer. Bad news. Nothing works.
Adding --tk in 1.5.1, main.exe is successfully created but when I
execute it (with or without python installed, without the imported
libraries) I get:
<<
Traceback (most recent call last):
File "<string>", line 22, in <module>
File "C:\pyinstaller-1.5.1\iu.py", line 436, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\pyinstaller-1.5.1\iu.py", line 521, in doimport
exec co in mod.__dict__
File "main\build\pyi.win32\main\outPYZ1.pyz/win32com.client", line
11, in <mod
ule>
File "C:\pyinstaller-1.5.1\iu.py", line 436, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\pyinstaller-1.5.1\iu.py", line 521, in doimport
exec co in mod.__dict__
File "main\build\pyi.win32\main\outPYZ1.pyz/
win32com.client.gencache", line 66
2, in <module>
File "main\build\pyi.win32\main\outPYZ1.pyz/
win32com.client.gencache", line 58
, in __init__
File "main\build\pyi.win32\main\outPYZ1.pyz/
win32com.client.gencache", line 64
9, in Rebuild
File "main\build\pyi.win32\main\outPYZ1.pyz/
win32com.client.gencache", line 65
, in _SaveDicts
File "main\build\pyi.win32\main\outPYZ1.pyz/
win32com.client.gencache", line 14
1, in GetGeneratePath
IOError: [Errno 22] invalid mode ('w') or filename: 'C:\
\pyinstaller-1.5.1\\main
\\dist\\main.exe?900671\\__init__.py'
>>

I don't understand what is going on. My program has dependencies on
pywin32 but I don't see what is the problem because I was able to run
the version without --tk *only* with tk/tcl or python (which includes
tk/tcl) installed, but this one doesn't even work when the former
works.

Using the current development version I got the following error and
main.exe was not even created:
python pyinstaller.py c:\stock_program\main.py
<<
wrote C:\pyinstaller-pyinstaller-830e51e\main\main.spec
INFO: Testing for ability to set icons, version resources...
INFO: ... resource update available
INFO: UPX is not available.
INFO: checking Analysis
INFO: building Analysis because out00-Analysis.toc non existent
INFO: running Analysis out00-Analysis.toc
INFO: Analyzing C:\pyinstaller-pyinstaller-830e51e\support
\_pyi_bootstrap.py
INFO: Analyzing c:\stock_program\main.py
WARNING: pythoncom is changing it's name to pythoncom27
ERROR: lib not found: MSVCR90.dll dependency of C:\Python27\DLLs
\_tkinter.pyd
Traceback (most recent call last):
File "pyinstaller.py", line 90, in <module>
main()
File "pyinstaller.py", line 85, in main
run_build(opts, spec_file)
File "pyinstaller.py", line 49, in run_build
PyInstaller.build.main(spec_file, **opts.__dict__)
File "C:\pyinstaller-pyinstaller-830e51e\PyInstaller\build.py", line
1570, in
main
build(specfile, buildpath)
File "C:\pyinstaller-pyinstaller-830e51e\PyInstaller\build.py", line
1480, in
build
execfile(spec)
File "C:\pyinstaller-pyinstaller-830e51e\main\main.spec", line 5, in
<module>
hookspath=None)
File "C:\pyinstaller-pyinstaller-830e51e\PyInstaller\build.py", line
369, in _
_init__
self.__postinit__()
File "C:\pyinstaller-pyinstaller-830e51e\PyInstaller\build.py", line
304, in _
_postinit__
self.assemble()
File "C:\pyinstaller-pyinstaller-830e51e\PyInstaller\build.py", line
433, in a
ssemble
importTracker.analyze_script(script)
File "C:\pyinstaller-pyinstaller-830e51e\PyInstaller\mf.py", line
589, in anal
yze_script
return self.analyze_r('__main__')
File "C:\pyinstaller-pyinstaller-830e51e\PyInstaller\mf.py", line
482, in anal
yze_r
newnms = self.analyze_one(name, nm, imptyp, level)
File "C:\pyinstaller-pyinstaller-830e51e\PyInstaller\mf.py", line
543, in anal
yze_one
mod = self.doimport(nm, ctx, fqname)
File "C:\pyinstaller-pyinstaller-830e51e\PyInstaller\mf.py", line
635, in doim
port
mod = self._handle_hook(mod, hook)
File "C:\pyinstaller-pyinstaller-830e51e\PyInstaller\mf.py", line
651, in _han
dle_hook
mod = hook.hook(mod)
File "C:\pyinstaller-pyinstaller-830e51e\PyInstaller\hooks\hook-
_tkinter.py",
line 83, in hook
tcl_tk = find_tk_win(binaries)
TypeError: find_tk_win() takes no arguments (1 given)
>>

Your thoughts?

Best

On Feb 2, 5:28 pm, Hartmut Goebel <h.goe...@goebel-consult.de> wrote:
> Am 30.01.2012 17:48, schrieb Spinel:
>
> > Any ideas on how to solve this? Did anybody come across this before?
>
> When using PyInstaller 1.5.1 you need to create your specfile with the
> --tk switch. This will add some magic to youe spec-file.
>
> Or try the current development version which does no longer require this
> magic and no longer requires the --tk switch.
>
> In the later case, please report success or failure and this part of the
> code is only a few weeks old.
>
> --
> Schönen Gruß - Regards
> Hartmut Goebel
> Dipl.-Informatiker (univ.), CISSP, CSSLP
>
> Goebel Consult
> Spezialist für IT-Sicherheit in komplexen Umgebungenhttp://www.goebel-consult.de
>
> Monatliche Kolumne:http://www.cissp-gefluester.de/
> Goebel Consult ist Mitglied beihttp://www.7-it.de
>
>  smime.p7s
> 8KViewDownload

Giovanni Bajo

unread,
Feb 6, 2012, 8:35:46 AM2/6/12
to pyins...@googlegroups.com

Please, use ArchiveViewer over the generated file (main.exe) and check
if win32comgenpy is bundled.

win32comgenpy is a runtime hook (support/rthooks/win32comgenpy.py) that
is executed before your application starts, and should configure
win32com so that it correctly use a temporary directory as the COM
cache.

If win32comegenpy is bundled, then you should debug why, even if it is
executed, win32com.client.gencache tries to go into the wrong directory.
Otherwise, I can help with the debugging, but I need you to provide a
small Python file that exhibits the same bug.

The current development version has not been fully tested on Windows
yet, there are some regressions. I've fixed this specific bug. Can you
please try again? It would be great if it ends up with the same error
than 1.5.

Another question: I see that, with the current development version, you
get this error:

ERROR: lib not found: MSVCR90.dll dependency of C:\Python27\DLLs
\_tkinter.pyd

Does it happen with 1.5.1? Can you try also with 1.5.0 and 1.4? That
would help us tracking a possible different bug.

Thanks!
--
Giovanni Bajo :: ra...@develer.com
Develer S.r.l. :: http://www.develer.com

My Blog: http://giovanni.bajo.it

spinel

unread,
Feb 6, 2012, 10:11:30 AM2/6/12
to PyInstaller
Using ArchiveViewer I can read:
(4485708, 857, 1710, 1, 's', 'win32comgenpy')
so I guess it is bundled.

I don't know how to debug this. I will send you example code in a
separate email.
Great job!! Now it generates main.exe perfectly and the program runs
with or without python and its libraries installed.

>
> Another question: I see that, with the current development version, you
> get this error:
>
> ERROR: lib not found: MSVCR90.dll dependency of C:\Python27\DLLs
> \_tkinter.pyd
>
> Does it happen with 1.5.1? Can you try also with 1.5.0 and 1.4? That
> would help us tracking a possible different bug.

No, in 1.5.1 it doesn't happen, with or without --tk. See:
<<
I: Searching for file msvcr90.dll
I: Found file C:\Windows\WinSxS
\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcr90.dll
I: Searching for file msvcp90.dll
I: Found file C:\Windows\WinSxS
\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcp90.dll
I: Searching for file msvcm90.dll
I: Found file C:\Windows\WinSxS
\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcm90.dll
I: Adding Microsoft.VC90.CRT.manifest
I: Adding msvcr90.dll
I: Adding msvcp90.dll
I: Adding msvcm90.dll
>>

I can't find 1.5.0 (in http://www.pyinstaller.org/wiki/OldDownloads)...Also
when I open 1.4's README I find 1.3 in its header?!
"python Configure.py" fails in 1.4. Do you still need me to test it?
With which version of Python should I try it?
<<
Traceback (most recent call last):
File "Configure.py", line 30, in <module>
import mf
File "C:\pyinstaller-1.4\mf.py", line 817, in <module>
JUMP_IF_FALSE = dis.opname.index('JUMP_IF_FALSE')
ValueError: 'JUMP_IF_FALSE' is not in list
>>

Best
Reply all
Reply to author
Forward
0 new messages