Tbaker
Tbaker

Reputation: 197

Pyinstaller compile to exe

I am trying to compile a Kivy application to a windows exe, but I keep receiving an attribute error: AttributeError: 'str' object has no attribute 'items'

I have compiled other applications, and followed the instructions line for line per the kivy page (completing the demo), but when I try to do the same to my application I receive the above error. I'm not sure where to go I've been trying for several hours now and I can't seem to make any headway. Any help would be greatly appreciated.

Edit: Below is the tail of the stack trace, the whole thing is long and so I pasted in what I think may be relevant, but frankly I'm a bit out of my depth here :)

6363 WARNING: stderr:   File "c:\python27\lib\site-packages\PyInstaller\depend\a
nalysis.py", line 198, in _safe_import_module
     hook_module.pre_safe_import_module(hook_api)
6375 WARNING: stderr:     hook_module.pre_safe_import_module(hook_api)
   File "c:\python27\lib\site-packages\PyInstaller\hooks\pre_safe_import_module\
hook-six.moves.py", line 55, in pre_safe_import_module
6378 WARNING: stderr:   File "c:\python27\lib\site-packages\PyInstaller\hooks\pr
e_safe_import_module\hook-six.moves.py", line 55, in pre_safe_import_module
     for real_module_name, six_module_name in real_to_six_module_name.items():
6388 WARNING: stderr:     for real_module_name, six_module_name in real_to_six_m
odule_name.items():
 AttributeError: 'str' object has no attribute 'items'
6396 WARNING: stderr: AttributeError: 'str' object has no attribute 'items'

My Spec:

# -*- mode: python -*-
from kivy.deps import sdl2, glew

block_cipher = None


a = Analysis(['face.py'],
             pathex=['c:\\Users\\Home\\PycharmProjects\\MSICheck\\Images'],
             binaries=None,
             datas=None,
             hiddenimports=['sqlite3','kivy.app','six','packaging','packaging.version','packaging.specifiers'],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
          name='face',
          debug=True,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(exe,Tree('c:\\Users\\Home\\PycharmProjects\\MSICheck\\Images\\'),
               a.binaries,
               a.zipfiles,
               a.datas,
               *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
               strip=False,
               upx=True,
               name='face')

EDIT: Apparently it has nothing to do with Kivy as I have rewritten the front end to use TKinter and i'm still having the issue.

Upvotes: 7

Views: 14455

Answers (8)

H2O2
H2O2

Reputation: 1

pip install --force-reinstall --no-binary :all: pyinstaller

Did the trick for me but only when running it into a command prompt as administrator....(Win10)

Upvotes: 0

Mohideen bin Mohammed
Mohideen bin Mohammed

Reputation: 20206

I have solved this by installing some dependencies,

pip install --force-reinstall --no-binary :all: pyinstaller

Here is the source issue link

Upvotes: 0

Shahansha Shaik
Shahansha Shaik

Reputation: 51

Things to check:

  • Check the output above the stated error. Sometimes some moudles required might not have been installed. Make sure that all modules are installed and no prior errors.
  • Upgrade setup tools using command :

    pip install --upgrade setuptools
    
  • Unistall and re-install modules like six, setuptools, pyinstaller also helps in some cases.

Upvotes: 4

Fatih1923
Fatih1923

Reputation: 2691

Despite upgrading the setuptools, Uninstalling and reinstalling works for me.

conda uninstall setuptools

and then

conda install setuptools

Upvotes: 2

Aaron Coffey
Aaron Coffey

Reputation: 71

I had a similar error when trying to compile my script to a macho using pyinstaller. I tried uninstalling/reinstalling six and setuptools as suggested elsewhere to no effect. I noticed another error regarding enum and tried uninstalling enum34 via pip. This did it.

pip uninstall enum34

Upvotes: 7

noname
noname

Reputation: 342

If you are still having this issue, here is what solved it for me:

pip install --upgrade setuptools

I've tried installing six (in my case, it wasn't already installed), but since it seems that it is looking for _vendor.six and not just six, that didn't solve it. Somehow, upgrading setuptools solves it.

Upvotes: 20

J Jones
J Jones

Reputation: 3200

I had similar error output from Pyinstaller with a wxPython project. It was solved it by upgrading setuptools (from 38.5.1 to 39.0.2).

Upvotes: 0

Sam Jia
Sam Jia

Reputation: 11

I have faced some similar error when I use pyinstaller. And part of my error message are showed following:

File "C:\Python27\lib\site-packages\pyinstaller-3.1.1-py2.7.egg\PyInstaller\depend\analysis.py", line 198, in _safe_import_module
  hook_module.pre_safe_import_module(hook_api)
File "C:\Python27\lib\site-packages\pyinstaller-3.1.1-py2.7.egg\PyInstaller\hooks\pre_safe_import_module\hook-six.moves.py", line 55, in pre_safe_import_module
  for real_module_name, six_module_name in real_to_six_module_name.items():
AttributeError: 'str' object has no attribute 'items'

When I scroll up this message, I found this:

18611 INFO: Processing pre-find module path hook   distutils
20032 INFO: Processing pre-safe import module hook   _xmlplus
23532 INFO: Processing pre-safe import module hook   six.moves
Traceback (most recent call last):
  File "<string>", line 2, in <module>
ImportError: No module named six

So I turned to install the module six. And when I installed it, my pyinstaller could run successfully.

Hope this can help you.

Upvotes: 1

Related Questions