KeyError: PYI_PYTHON_LIBRARY_NAME --> Is this a known bug? Is there a easy workaround for this?

344 views
Skip to first unread message

Ram

unread,
Jan 7, 2013, 12:43:50 AM1/7/13
to pyins...@googlegroups.com

When I try to compile my project using pyinstaller, it hits this: (win7 + vs2010 shell + pyinstaller from github)

2868 INFO: building PKG out00-PKG.pkg
Traceback (most recent call last):
  File "C:\cygwin\tmp\pyinstaller\pyinstaller.py", line 91, in <module>
    main()
  File "C:\cygwin\tmp\pyinstaller\pyinstaller.py", line 86, in main
    run_build(opts, spec_file)
  File "C:\cygwin\tmp\pyinstaller\pyinstaller.py", line 50, in run_build
    PyInstaller.build.main(spec_file, **opts.__dict__)
  File "C:\cygwin\tmp\pyinstaller\PyInstaller\build.py", line 1694, in main
    build(specfile, buildpath)
  File "C:\cygwin\tmp\pyinstaller\PyInstaller\build.py", line 1651, in build
    execfile(spec)
  File "proj.spec", line 26, in <module>
    icon='../resources/images/projicon.ico')
  File "C:\cygwin\tmp\pyinstaller\PyInstaller\build.py", line 1060, in __init__
    strip_binaries=self.strip, upx_binaries=self.upx,
  File "C:\cygwin\tmp\pyinstaller\PyInstaller\build.py", line 951, in __init__
    self.__postinit__()
  File "C:\cygwin\tmp\pyinstaller\PyInstaller\build.py", line 312, in __postinit
__
    self.assemble()
  File "C:\cygwin\tmp\pyinstaller\PyInstaller\build.py", line 1006, in assemble
    pylib_name=os.environ['PYI_PYTHON_LIBRARY_NAME'])
  File "c:\Python27\lib\os.py", line 423, in __getitem__
    return self.data[key.upper()]
KeyError: 'PYI_PYTHON_LIBRARY_NAME'

What is the correct way of fixing this?

Thanks.

Martin Zibricky

unread,
Jan 7, 2013, 5:51:18 PM1/7/13
to pyins...@googlegroups.com
Ram píše v Ne 06. 01. 2013 v 21:43 -0800:
> What is the correct way of fixing this?

Could you please try latest dev version? It should be fixed there.

Ram

unread,
Jan 8, 2013, 9:43:51 AM1/8/13
to pyins...@googlegroups.com


Thanks Martin. The new code on github fixed this problem but created another problem. Now my executables dump other errors when run.

The main problem being that it cant find the Python DLL when run. This seems to be related to the fix you just did. I was able to make my code compile and work with an earlier version of pyinstaller I had.

Thanks.

Martin Zibricky

unread,
Jan 8, 2013, 3:54:30 PM1/8/13
to pyins...@googlegroups.com
Ram píše v Út 08. 01. 2013 v 06:43 -0800:
> Thanks Martin. The new code on github fixed this problem but created
> another problem. Now my executables dump other errors when run.
>
> The main problem being that it cant find the Python DLL when run. This
> seems to be related to the fix you just did. I was able to make my
> code compile and work with an earlier version of pyinstaller I had.
>
> Thanks.

Could you please test my branch if that could potentially fix some of
your other errors?

git://github.com/matysek/pyinstaller.git

Thanks

Ram

unread,
Jan 8, 2013, 9:57:30 PM1/8/13
to pyins...@googlegroups.com

Here is what happens with this version:

12530 INFO: Processing hook hook-parser

Traceback (most recent call last):
  File "c:\cygwin\tmp\temp\pyinstaller\pyinstaller.py", line 91, in <module>
    main()
  File "c:\cygwin\tmp\temp\pyinstaller\pyinstaller.py", line 86, in main
    run_build(opts, spec_file)
  File "c:\cygwin\tmp\temp\pyinstaller\pyinstaller.py", line 50, in run_build
    PyInstaller.build.main(spec_file, **opts.__dict__)
  File "c:\cygwin\tmp\temp\pyinstaller\PyInstaller\build.py", line 1653, in main
    build(specfile, buildpath)
  File "c:\cygwin\tmp\temp\pyinstaller\PyInstaller\build.py", line 1610, in build
    execfile(spec)
  File ".\Blib.spec", line 10, in <module>
    hookspath=None)
  File "c:\cygwin\tmp\temp\pyinstaller\PyInstaller\build.py", line 392, in __init__
    self.__postinit__()
  File "c:\cygwin\tmp\temp\pyinstaller\PyInstaller\build.py", line 312, in __postinit__
    self.assemble()
  File "c:\cygwin\tmp\temp\pyinstaller\PyInstaller\build.py", line 545, in assemble
    importTracker.analyze_script(script)
  File "c:\cygwin\tmp\temp\pyinstaller\PyInstaller\depend\imptracker.py", line 256, in analyze_script
    return self.analyze_r('__main__')
  File "c:\cygwin\tmp\temp\pyinstaller\PyInstaller\depend\imptracker.py", line 149, in analyze_r
    newnms = self.analyze_one(name, nm, imptyp, level)
  File "c:\cygwin\tmp\temp\pyinstaller\PyInstaller\depend\imptracker.py", line 210, in analyze_one
    mod = self.doimport(nm, ctx, fqname)
  File "c:\cygwin\tmp\temp\pyinstaller\PyInstaller\depend\imptracker.py", line 307, in doimport
    hooks = __import__('PyInstaller.hooks', globals(), locals(), [hookmodnm])
  File "c:\cygwin\tmp\temp\pyinstaller\PyInstaller\hooks\hook-django.py", line 36, in <module>
    raise RuntimeError("No django root directory found. Please check your "
RuntimeError: No django root directory found. Please check your pathex definition in the project spec file.

Hope you can fix this and perhaps I can try again?

Thanks.

Martin Zibricky

unread,
Jan 9, 2013, 5:11:46 AM1/9/13
to pyins...@googlegroups.com
Ram píše v Út 08. 01. 2013 v 18:57 -0800:
> File "c:\cygwin\tmp\temp\pyinstaller\PyInstaller\hooks
> \hook-django.py", line 36, in <module>
> raise RuntimeError("No django root directory found. Please check
> your "
> RuntimeError: No django root directory found. Please check your pathex
> definition in the project spec file.
>
> Hope you can fix this and perhaps I can try again?
> Thanks.

This is the famous django issue. More people already complained about
django. There could be multiple issues involved.

Probably it's time to fix django.

Do you think any of them could be related?
http://www.pyinstaller.org/ticket/414
http://www.pyinstaller.org/ticket/567
http://www.pyinstaller.org/ticket/581
http://www.pyinstaller.org/ticket/618
http://www.pyinstaller.org/ticket/642
http://www.pyinstaller.org/ticket/645

What is your django version?
What is your django project structure?
- where are your 'settings.py' and 'manage.py'?

Thanks



Ram

unread,
Jan 9, 2013, 10:24:45 PM1/9/13
to pyins...@googlegroups.com

Hi Matin,

Thanks for the quick reply. I do not have django installed. 

$ pip uninstall django
Cannot uninstall requirement django, not installed

I made these changes in the hook-django.py and my code compiled:

django_root_dirs = []
hiddenimports = []
compat.setenv("PYTHONPATH", python_path)
#
#for path in python_path.split(os.pathsep):
#    django_root_dirs.extend(find_django_root(path))
#
#if not django_root_dirs:
#    raise RuntimeError("No django root directory found. Please check your "
#                       "pathex definition in the project spec file.")
#
#if django_root_dirs[0] in PyInstaller.__pathex__:
#    raise RuntimeError("The django root directory is defined in the pathex. "
#                       "You have to define the parent directory instead of "
#                       "the django root directory.")
#
#compat.setenv("PYTHONPATH", python_path)
#

Thanks.

Ram

unread,
Jan 9, 2013, 11:22:36 PM1/9/13
to pyins...@googlegroups.com

It compiled using the django-hook fix. Now when I run it:

$ ./dist/Proj/ProjConsole.exe
Process Proj Main Process:
Traceback (most recent call last):
  File "C:\cygwin\home\joe\Exp\Proj_2012_April\pyi.win32\Proj\out01-PYZ.pyz\multiprocessing.process", line 258, in _bootstrap
  File "C:\cygwin\home\joe\Exp\Proj_2012_April\pyi.win32\Proj\out01-PYZ.pyz\Proj.startup.ProjProcess", line 42, in run
  File "C:\cygwin\home\joe\Exp\Proj_2012_April\pyi.win32\Proj\out01-PYZ.pyz\multiprocessing.process", line 114, in run
  File "C:\cygwin\home\joe\Exp\Proj_2012_April\pyi.win32\Proj\out01-PYZ.pyz\Proj.startup.ProjProcess", line 67, in startProjProcess
  File "C:\cygwin\home\joe\Exp\Proj_2012_April\pyi.win32\Proj\out01-PYZ.pyz\Proj.startup.instances._base", line 290, in run
  File "C:\cygwin\home\joe\Exp\Proj_2012_April\pyi.win32\Proj\out01-PYZ.pyz\Proj.startup.instances._base", line 101, in startup
  File "C:\cygwin\home\joe\Exp\Proj_2012_April\pyi.win32\Proj\out01-PYZ.pyz\Proj.startup.instances._base", line 127, in _startup
  File "C:\cygwin\home\joe\Exp\Proj_2012_April\pyi.win32\Proj\out01-PYZ.pyz\Proj.tools.logconfig", line 91, in setup_logging_server
AttributeError: 'module' object has no attribute 'listenTCP'

(listenTCP is a function in Twisted 12.3 reactor)
Any ideas how to fix this? This runs with an earlier version of pyinstaller I have. 

Thanks.

Martin Zibricky

unread,
Jan 10, 2013, 5:53:30 AM1/10/13
to pyins...@googlegroups.com
Ram píše v St 09. 01. 2013 v 20:22 -0800:
> AttributeError: 'module' object has no attribute 'listenTCP'
>
> (listenTCP is a function in Twisted 12.3 reactor) Any ideas how to fix
> this? This runs with an earlier version of pyinstaller I have.

What pyinstaller version are you referring to? 2.0 or earlier dev
version?

Martin Zibricky

unread,
Jan 10, 2013, 6:06:59 AM1/10/13
to pyins...@googlegroups.com
This is really interesting:
- the django hook is processed even not having django installed
- pyinstaller should not process django-hook when django is not
installed

It seems like a serious bug in pyinstaller.

What python modules do you use? Does any of them have optional
dependency on django?

Could you please look at the file if 'django' is there?

./build/pyi.linux2/YOUR_APP/warnYOUR_APP.txt

Thanks.


Ram píše v St 09. 01. 2013 v 19:24 -0800:

Martin Zibricky

unread,
Jan 10, 2013, 5:46:22 PM1/10/13
to pyins...@googlegroups.com
Ram píše v St 09. 01. 2013 v 20:22 -0800:
> setup_logging_server AttributeError: 'module' object has no attribute
> 'listenTCP'
>
> (listenTCP is a function in Twisted 12.3 reactor) Any ideas how to fix
> this? This runs with an earlier version of pyinstaller I have.

Please test again with my latest branch.

I added there a rthook for twisted module and the following example is
now working for me with pyinstaller:

http://twistedmatrix.com/documents/current/conch/examples/sshsimpleserver.py


Ram

unread,
Jan 10, 2013, 11:12:15 PM1/10/13
to pyins...@googlegroups.com


That bug is gone now, but PyQT does not even fire up. :(
No error at all. Just no output or window.

Thanks.

Martin Zibricky

unread,
Jan 11, 2013, 3:38:24 AM1/11/13
to pyins...@googlegroups.com
Ram píše v Čt 10. 01. 2013 v 20:12 -0800:
> That bug is gone now, but PyQT does not even fire up. :(
> No error at all. Just no output or window.
>
> Thanks.

Do you use the qtreactor?

https://twistedmatrix.com/trac/wiki/QTReactor

Ram

unread,
Jan 11, 2013, 10:09:04 PM1/11/13
to pyins...@googlegroups.com


Indeed I use QTReactor for running twisted + QT.

Martin Zibricky

unread,
Jan 12, 2013, 5:00:54 AM1/12/13
to pyins...@googlegroups.com
Ram píše v Pá 11. 01. 2013 v 19:09 -0800:
> Indeed I use QTReactor for running twisted + QT.

Then you need to remove file ./support/rthooks/pyi_rth_twisted.py

and at the top of your main script run code like


from twisted.internet import protocol
import qtreactor
app = QApplication([])
qtreactor.install(app)


https://twistedmatrix.com/users/pahan/qt_files/qtdemo.py

Hartmut Goebel

unread,
Jan 12, 2013, 5:50:39 AM1/12/13
to pyins...@googlegroups.com
Am 12.01.2013 11:00, schrieb Martin Zibricky:
and at the top of your main script run code like

from twisted.internet import protocol
import qtreactor
app = QApplication([])
qtreactor.install(app)

This would by a good case for a custom runtime-hook, we could provide, couldn't we?
And for a wiki-entry describing this.

@Ram: Would be great if you'd submit both a runtime-hook and a wiki-entry :-)

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

Goebel Consult
http://www.goebel-consult.de

Monatliche Kolumne: http://www.cissp-gefluester.de/2012-04-compliance-bringt-keine-sicherheit
Blog: http://www.goebel-consult.de/blog/20041011

Goebel Consult ist Mitglied bei http://www.7-it.de/

Martin Zibricky

unread,
Jan 13, 2013, 7:15:00 AM1/13/13
to pyins...@googlegroups.com
I was thinking about a new wiki recipe. Thanks for reminder.

Hartmut Goebel píše v So 12. 01. 2013 v 11:50 +0100:

Ram

unread,
Jan 14, 2013, 12:10:30 AM1/14/13
to pyins...@googlegroups.com

Two problems:

1. When I checked out git://github.com/matysek/pyinstaller.git , I dont see a support directory in there anymore.

2. In my previous version that I had saved, when I removed the
file ./support/rthooks/pyi_rth_twisted.py, I got a listenTCP Error even in the program that used to work without removing the file.

Thanks.

Martin Zibricky

unread,
Jan 14, 2013, 7:38:00 AM1/14/13
to pyins...@googlegroups.com
Ram píše v Ne 13. 01. 2013 v 21:10 -0800:
>
> Two problems:
>
> 1. When I checked out git://github.com/matysek/pyinstaller.git , I
> dont see a support directory in there anymore.

I did some other changes moved some files to another directories.

./support/rthooks/pyi_rth_twisted.py is now in

./PyInstaller/loader/rthooks/pyi_rth_twisted.py

> 2. In my previous version that I had saved, when I removed the
> file ./support/rthooks/pyi_rth_twisted.py, I got a listenTCP Error
> even in the program that used to work without removing the file.

- The file pyi_rth_twisted installs the default reactor before your code
imports anything from 'twisted' module.
- this hook does not work for you since you use qtreactor and not the
default reactor from twisted.
- you have to run the code that installs proper
'twisted.internet.reactor' before any other code.

You will have try to find proper code to initialize qtreactor.

> On Sunday, January 13, 2013 7:15:00 AM UTC-5, Martin Z wrote:
> I was thinking about a new wiki recipe. Thanks for reminder.
>
> Hartmut Goebel píše v So 12. 01. 2013 v 11:50 +0100:
> > Am 12.01.2013 11:00, schrieb Martin Zibricky:
> > > and at the top of your main script run code like
> > >
> > > from twisted.internet import protocol
> > > import qtreactor
> > > app = QApplication([])
> > > qtreactor.install(app)
> >
> > This would by a good case for a custom runtime-hook, we
> could provide,
> > couldn't we?
> > And for a wiki-entry describing this.
> >
> > @Ram: Would be great if you'd submit both a runtime-hook and
> a
> > wiki-entry :-)
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "PyInstaller" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pyinstaller/-/6KRcRD2cZh0J.
> To post to this group, send email to pyins...@googlegroups.com.
> To unsubscribe from this group, send email to pyinstaller
> +unsub...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pyinstaller?hl=en.


Ram

unread,
Jan 14, 2013, 1:02:58 PM1/14/13
to pyins...@googlegroups.com

Thanks Martin. I'm using

import qt4reactor

and then use qt4reactor.install()

This is run when the code is run. Is that a problem? Still stuck on "listenTCP" not found, which means the reactor is having trouble, like you said.

Martin Zibricky

unread,
Jan 14, 2013, 1:20:32 PM1/14/13
to pyins...@googlegroups.com
I would recommend to first try package the qtreactor example and then
you could move on to your app since there could be multiple issues
involved.

Ram píše v Po 14. 01. 2013 v 10:02 -0800:

Ram

unread,
Jan 14, 2013, 11:40:35 PM1/14/13
to pyins...@googlegroups.com

I created a small python program on the basis of what you had said in an earlier email. Used your pyinstaller github repo version to compile. Here are the details of the compilation and the error I got:

$ cat test.py
from twisted.internet import protocol
from PyQt4.QtGui import QApplication
import qt4reactor
app = QApplication([])
qt4reactor.install()

$ python ../pyinstaller/pyinstaller.py --onefile test.py
fatal: Not a git repository (or any of the parent directories): .git
42 INFO: wrote C:\cygwin\tmp\test\test.spec
72 INFO: Testing for ability to set icons, version resources...
75 ERROR: ... resource update unavailable - C:\cygwin\tmp\pyinstaller\support\loader\Windows-32bit\r
unw.exe not found
82 INFO: UPX is not available.
111 INFO: Processing hook hook-os
305 INFO: Processing hook hook-time
373 INFO: Processing hook hook-_sre
411 INFO: Processing hook hook-cStringIO
425 INFO: Processing hook hook-codecs
458 INFO: Processing hook hook-encodings
1134 INFO: Processing hook hook-cPickle
1397 INFO: Processing hook hook-httplib
1409 INFO: Processing hook hook-email
1577 INFO: Processing hook hook-email.message
1951 WARNING: library python%s%s required via ctypes not found
2139 INFO: checking Analysis
2141 INFO: building Analysis because out00-Analysis.toc non existent
2143 INFO: running Analysis out00-Analysis.toc
2152 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
2269 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
2271 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21
022.8_none_bcb86ed6ac711f91.manifest
2276 INFO: Searching for file msvcr90.dll
2278 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb
86ed6ac711f91\msvcr90.dll
2282 INFO: Searching for file msvcp90.dll
2285 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb
86ed6ac711f91\msvcp90.dll
2289 INFO: Searching for file msvcm90.dll
2291 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb
86ed6ac711f91\msvcm90.dll
2392 INFO: Analyzing C:\cygwin\tmp\pyinstaller\PyInstaller\loader\_pyi_bootstrap.py
2416 INFO: Processing hook hook-os
2437 INFO: Processing hook hook-site
2640 INFO: Processing hook hook-time
2713 INFO: Processing hook hook-_sre
2749 INFO: Processing hook hook-cStringIO
2763 INFO: Processing hook hook-codecs
2782 INFO: Processing hook hook-encodings
3465 INFO: Processing hook hook-cPickle
3722 INFO: Processing hook hook-httplib
3731 INFO: Processing hook hook-email
3902 INFO: Processing hook hook-email.message
4280 WARNING: library python%s%s required via ctypes not found
4502 INFO: Processing hook hook-pydoc
4625 INFO: Analyzing C:\cygwin\tmp\pyinstaller\PyInstaller\loader\pyi_importers.py
4953 INFO: Analyzing C:\cygwin\tmp\pyinstaller\PyInstaller\loader\pyi_archive.py
5249 INFO: Analyzing C:\cygwin\tmp\pyinstaller\PyInstaller\loader\pyi_carchive.py
5525 INFO: Analyzing C:\cygwin\tmp\pyinstaller\PyInstaller\loader\pyi_os_path.py
5550 INFO: Analyzing test.py
5557 INFO: Processing hook hook-PyQt4
5558 INFO: Processing hook hook-PyQt4.QtGui
6097 INFO: Processing hook hook-PyQt4.QtCore
6596 INFO: Processing hook hook-xml
6684 INFO: Processing hook hook-xml.dom
6718 INFO: Processing hook hook-xml.sax
6771 INFO: Processing hook hook-pyexpat
6786 INFO: Processing hook hook-xml.dom.domreg
7201 INFO: Processing hook hook-pywintypes
7462 INFO: Hidden import 'encodings' has been found otherwise
7462 INFO: Looking for run-time hooks
7463 INFO: Analyzing rthook C:\cygwin\tmp\pyinstaller\PyInstaller\loader\rthooks\pyi_rth_qt4plugins.
py
7766 INFO: Analyzing rthook C:\cygwin\tmp\pyinstaller\PyInstaller\loader\rthooks\pyi_rth_encodings.p
y
14424 INFO: Using Python library C:\Windows\system32\python27.dll
14511 INFO: Warnings written to C:\cygwin\tmp\test\build\pyi.win32\test\warntest.txt
14525 INFO: checking PYZ
14525 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
14525 INFO: building PYZ out00-PYZ.toc
16277 INFO: checking PKG
16278 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
16278 INFO: building PKG out00-PKG.pkg
22053 INFO: checking EXE
22054 INFO: rebuilding out00-EXE.toc because test.exe missing
22054 INFO: building EXE from out00-EXE.toc
22058 INFO: Appending archive to EXE C:\cygwin\tmp\test\dist\test.exe

$ ./dist/test.exe
WARNING: file already exists but should not: C:/Users/joe/AppData/Local/Temp/_MEI80722\.\pywintypes27.dll

Runtime Error: Program C:\cygwin\tmp\test\dist\test.exe
R6034
An application has made an attempt to load a C runtime library incorectly.
Please contact the application's support team for more information.

Martin Zibricky

unread,
Jan 15, 2013, 4:05:08 AM1/15/13
to pyins...@googlegroups.com
Ram píše v Po 14. 01. 2013 v 20:40 -0800:
> $ python ../pyinstaller/pyinstaller.py --onefile test.py

Try it with --onedir mode.

Ram

unread,
Jan 16, 2013, 12:53:41 AM1/16/13
to pyins...@googlegroups.com

Martin,

--onedir seems to work. Why does the --onefile not work?

Also: how do i get my complete project compiled since it does not just use exactly the same snippet.

Thanks.

Martin Zibricky

unread,
Jan 16, 2013, 6:13:07 AM1/16/13
to pyins...@googlegroups.com
Ram píše v Út 15. 01. 2013 v 21:53 -0800:
> Martin,
>
> --onedir seems to work. Why does the --onefile not work?

Good to hear. I don't know why --onefile does not work. There could be
more things involved.

> Also: how do i get my complete project compiled since it does not just
> use exactly the same snippet.

Start with --onedir mode and ensure that your project initializes qt and
qtreactor the same way as that snippet.

Reply all
Reply to author
Forward
0 new messages