Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Ground Controller Lvl 1
Message 1 of 2

Errors with installing executable from .py script with pyinstaller

I've been working on a script that retrieves data from Twitter's API. But when I use the pyinstaller --onefile command, I get errors that prevent an executable file from being created. There are a number of errors that occur and I've searched various forums but alas no solutions thus far. These are the following modules I've imported if it helps:

 

import tweepy
import time
import numpy as np
from datetime import datetime, date, timedelta
from collections import Counter
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

 

-------------------------------------------------------------------------------------------------------------

 

Below is the log that appears in my terminal when pyinstaller tries to install the .py script into an executable

 

102 INFO: PyInstaller: 3.4
102 INFO: Python: 3.7.2
112 INFO: Platform: Darwin-18.2.0-x86_64-i386-64bit
113 INFO: wrote /Users/blacksnowball/Documents/python_project/twitter_final.spec
116 INFO: UPX is not available.
119 INFO: Extending PYTHONPATH with paths
['/Users/blacksnowball/Documents/python_project',
 '/Users/blacksnowball/Documents/python_project']
119 INFO: checking Analysis
120 INFO: Building Analysis because Analysis-00.toc is non existent
120 INFO: Initializing module dependency graph...
123 INFO: Initializing module graph hooks...
126 INFO: Analyzing base_library.zip ...
3055 INFO: running Analysis Analysis-00.toc
3062 INFO: Caching module hooks...
3068 INFO: Analyzing /Users/blacksnowball/Documents/python_project/twitter_final.py
3201 INFO: Processing pre-safe import module hook   six.moves
3377 INFO: Processing pre-safe import module hook   urllib3.packages.six.moves
5239 INFO: Processing pre-find module path hook   distutils
6211 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
6581 INFO: Processing pre-find module path hook   site
6582 INFO: site: retargeting to fake-dir '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/PyInstaller/fake-modules'
20197 INFO: Loading module hooks...
20197 INFO: Loading module hook "hook-sqlite3.py"...
20254 INFO: Loading module hook "hook-pkg_resources.py"...
20484 INFO: Processing pre-safe import module hook   win32com
20637 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
20638 INFO: Loading module hook "hook-lib2to3.py"...
20642 INFO: Loading module hook "hook-_tkinter.py"...
20646 ERROR: Tcl/Tk improperly installed on this system.
20646 INFO: Loading module hook "hook-encodings.py"...
20699 INFO: Loading module hook "hook-IPython.py"...
20719 INFO: Excluding import 'PyQt4'
20724 INFO: Excluding import 'PySide'
20728 INFO: Excluding import 'tkinter'
20731 INFO:   Removing import of tkinter from module IPython.lib.clipboard
20732 INFO: Excluding import 'PyQt5'
20737 INFO: Import to be excluded not found: 'gtk'
20737 INFO: Excluding import 'matplotlib'
20740 INFO:   Removing import of matplotlib.pyplot from module IPython.core.pylabtools
20740 INFO:   Removing import of matplotlib from module IPython.core.pylabtools
20740 INFO:   Removing import of matplotlib.figure from module IPython.core.pylabtools
20741 INFO:   Removing import of matplotlib._pylab_helpers from module IPython.core.pylabtools
20742 INFO: Loading module hook "hook-PIL.py"...
20745 INFO: Excluding import 'PyQt4'
20747 INFO:   Removing import of PyQt4 from module PIL.ImageQt
20747 INFO: Excluding import 'PySide'
20749 INFO:   Removing import of PySide from module PIL.ImageQt
20749 INFO: Excluding import 'tkinter'
20751 INFO: Excluding import 'PyQt5'
20753 INFO:   Removing import of PyQt5 from module PIL.ImageQt
20753 INFO: Import to be excluded not found: 'FixTk'
20753 INFO: Loading module hook "hook-setuptools.py"...
21227 INFO: Loading module hook "hook-pycparser.py"...
21463 INFO: Loading module hook "hook-matplotlib.py"...
21716 INFO: Loading module hook "hook-xml.dom.domreg.py"...
21717 INFO: Loading module hook "hook-PIL.Image.py"...
22022 INFO: Loading module hook "hook-jedi.py"...
22026 INFO: Loading module hook "hook-certifi.py"...
22027 INFO: Loading module hook "hook-matplotlib.backends.py"...
22552 INFO:   Matplotlib backend "GTK3Agg": ignored
    Traceback (most recent call last):
  File "<string>", line 12, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_gtk3agg.py", line 6, in <module>
    from . import backend_agg, backend_cairo, backend_gtk3
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_cairo.py", line 19, in <module>
    import cairocffi as cairo
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/__init__.py", line 39, in <module>
    cairo = dlopen(ffi, 'cairo', 'cairo-2', 'cairo-gobject-2', 'cairo.so.2')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/__init__.py", line 36, in dlopen
    raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2 / cairo-gobject-2 / cairo.so.2
22805 INFO:   Matplotlib backend "GTK3Cairo": ignored
    Traceback (most recent call last):
  File "<string>", line 12, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_gtk3cairo.py", line 1, in <module>
    from . import backend_cairo, backend_gtk3
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_cairo.py", line 19, in <module>
    import cairocffi as cairo
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/__init__.py", line 39, in <module>
    cairo = dlopen(ffi, 'cairo', 'cairo-2', 'cairo-gobject-2', 'cairo.so.2')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/__init__.py", line 36, in dlopen
    raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2 / cairo-gobject-2 / cairo.so.2
23268 INFO:   Matplotlib backend "MacOSX": added
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/IPython/kernel/__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated since IPython 4.0.You should import from ipykernel or jupyter_client instead.
  "You should import from ipykernel or jupyter_client instead.", ShimWarning)
23956 INFO:   Matplotlib backend "nbAgg": ignored
    No module named 'ipykernel'
24219 INFO:   Matplotlib backend "Qt4Agg": ignored
    Failed to import any qt binding
24476 INFO:   Matplotlib backend "Qt4Cairo": ignored
    Traceback (most recent call last):
  File "<string>", line 12, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_qt4cairo.py", line 1, in <module>
    from .backend_qt5cairo import _BackendQT5Cairo
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_qt5cairo.py", line 3, in <module>
    from .backend_cairo import cairo, FigureCanvasCairo, RendererCairo
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_cairo.py", line 19, in <module>
    import cairocffi as cairo
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/__init__.py", line 39, in <module>
    cairo = dlopen(ffi, 'cairo', 'cairo-2', 'cairo-gobject-2', 'cairo.so.2')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/__init__.py", line 36, in dlopen
    raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2 / cairo-gobject-2 / cairo.so.2
24731 INFO:   Matplotlib backend "Qt5Agg": ignored
    Failed to import any qt binding
24980 INFO:   Matplotlib backend "Qt5Cairo": ignored
    Traceback (most recent call last):
  File "<string>", line 12, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_qt5cairo.py", line 3, in <module>
    from .backend_cairo import cairo, FigureCanvasCairo, RendererCairo
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_cairo.py", line 19, in <module>
    import cairocffi as cairo
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/__init__.py", line 39, in <module>
    cairo = dlopen(ffi, 'cairo', 'cairo-2', 'cairo-gobject-2', 'cairo.so.2')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/__init__.py", line 36, in dlopen
    raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2 / cairo-gobject-2 / cairo.so.2
25336 INFO:   Matplotlib backend "TkAgg": added
25680 INFO:   Matplotlib backend "TkCairo": ignored
    Traceback (most recent call last):
  File "<string>", line 12, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_tkcairo.py", line 6, in <module>
    from .backend_cairo import cairo, FigureCanvasCairo, RendererCairo
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_cairo.py", line 19, in <module>
    import cairocffi as cairo
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/__init__.py", line 39, in <module>
    cairo = dlopen(ffi, 'cairo', 'cairo-2', 'cairo-gobject-2', 'cairo.so.2')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/__init__.py", line 36, in dlopen
    raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2 / cairo-gobject-2 / cairo.so.2
26020 INFO:   Matplotlib backend "WebAgg": added
26485 INFO:   Matplotlib backend "WX": added
26863 INFO:   Matplotlib backend "WXAgg": added
27158 INFO:   Matplotlib backend "WXCairo": ignored
    Traceback (most recent call last):
  File "<string>", line 12, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_wxcairo.py", line 3, in <module>
    from .backend_cairo import cairo, FigureCanvasCairo, RendererCairo
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_cairo.py", line 19, in <module>
    import cairocffi as cairo
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/__init__.py", line 39, in <module>
    cairo = dlopen(ffi, 'cairo', 'cairo-2', 'cairo-gobject-2', 'cairo.so.2')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/__init__.py", line 36, in dlopen
    raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2 / cairo-gobject-2 / cairo.so.2
27398 INFO:   Matplotlib backend "agg": added
27644 INFO:   Matplotlib backend "cairo": ignored
    Traceback (most recent call last):
  File "<string>", line 12, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/backends/backend_cairo.py", line 19, in <module>
    import cairocffi as cairo
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/__init__.py", line 39, in <module>
    cairo = dlopen(ffi, 'cairo', 'cairo-2', 'cairo-gobject-2', 'cairo.so.2')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cairocffi/__init__.py", line 36, in dlopen
    raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2 / cairo-gobject-2 / cairo.so.2
27990 INFO:   Matplotlib backend "pdf": added
28320 INFO:   Matplotlib backend "pgf": added
28560 INFO:   Matplotlib backend "ps": added
28812 INFO:   Matplotlib backend "svg": added
29145 INFO:   Matplotlib backend "template": added
29660 INFO: Loading module hook "hook-sysconfig.py"...
29668 INFO: Loading module hook "hook-numpy.core.py"...
29725 INFO: Loading module hook "hook-xml.py"...
29726 INFO: Loading module hook "hook-pydoc.py"...
29726 INFO: Loading module hook "hook-nltk.py"...
Unable to find "/Users/blacksnowball/nltk_data" when adding binary and data files.

 

Any help is appreciated!

 

1 Reply
Pilot Lvl 2
Message 2 of 2

Re: Errors with installing executable from .py script with pyinstaller

Theres a lot to process there. You may be dragging some dependencies in via the installer which you don't need.

 

For instance, the first error is "TCL/Tk improperly installed on this system". Can you configure the installer to remove all reference to TCL/Tk? _Is_ TCL/Tk properly installed?

 

Matlib seems to be unhappy about Cairo. Can the installer be prevented from referencing Matlib/Cairo?