简体   繁体   中英

pyinstaller 3.3.1 doesn't work with openpyxl 2.4.1

I have a large program I'm trying to package with pyinstaller and have discovered that the problem is the openpyxl package.

Here is a minimal program:

import openpyxl
print("Hello World")

Here is the command that I am using to run pyinstaller:

$ pyinstaller --onefile demo2.py

Here is the output:

$ pyinstaller --onefile demo2.py
461 INFO: PyInstaller: 3.3.1
461 INFO: Python: 3.6.0
470 INFO: Platform: Darwin-18.0.0-x86_64-i386-64bit
471 INFO: wrote /Users/user/gits/drb_rounder/python/demo2.spec
475 INFO: UPX is not available.
476 INFO: Extending PYTHONPATH with paths
['/Users/user/gits/drb_rounder/python',
 '/Users/user/gits/drb_rounder/python']
476 INFO: checking Analysis
579 INFO: Building because /Users/user/gits/drb_rounder/python/demo2.py changed
579 INFO: Initializing module dependency graph...
585 INFO: Initializing module graph hooks...
587 INFO: Analyzing base_library.zip ...
4887 INFO: running Analysis out00-Analysis.toc
4898 INFO: Caching module hooks...
4902 INFO: Analyzing /Users/user/gits/drb_rounder/python/demo2.py
6692 INFO: Processing pre-find module path hook   distutils
10268 INFO: Processing pre-find module path hook   site
10269 INFO: site: retargeting to fake-dir '/Users/user/anaconda3/lib/python3.6/site-packages/PyInstaller/fake-modules'
10296 INFO: Processing pre-safe import module hook   win32com
12225 INFO: Processing pre-safe import module hook   six.moves
23816 INFO: Processing pre-safe import module hook   

requests.packages.urllib3.packages.six.moves
    Traceback (most recent call last):
      File "/Users/user/anaconda3/bin/pyinstaller", line 11, in <module>
        sys.exit(run())
      File "/Users/user/anaconda3/lib/python3.6/site-packages/PyInstaller/__main__.py", line 94, in run
        run_build(pyi_config, spec_file, **vars(args))
...
packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1576, in _find_head_package
        target_module_headname, target_package_name, source_package)
      File "/Users/user/anaconda3/lib/python3.6/site-packages/PyInstaller/depend/analysis.py", line 271, in _safe_import_module
        module_basename, module_name, parent_package)
      File "/Users/user/anaconda3/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1993, in _safe_import_module
        module_name, file_handle, pathname, metadata)
      File "/Users/user/anaconda3/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2031, in _load_module
        m = self._load_package(fqname, pathname, packagepath)
      File "/Users/user/anaconda3/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2789, in _load_package
        ns_pkgpath = _namespace_package_path(fqname, pkgpath or [], self.path)
      File "/Users/user/anaconda3/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 147, in _namespace_package_path
        working_set = pkg_resources.WorkingSet(path)
      File "/Users/user/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/__init__.py", line 644, in __init__
      File "/Users/user/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/__init__.py", line 700, in add_entry
      File "/Users/user/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/__init__.py", line 1990, in find_on_path
      File "/Users/user/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/__init__.py", line 2399, in from_location
      File "/Users/user/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/__init__.py", line 2378, in __init__
      File "/Users/user/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/__init__.py", line 1387, in safe_version
      File "/Users/user/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/_vendor/packaging/version.py", line 207, in __init__
      File "/Users/user/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/_vendor/packaging/version.py", line 207, in <genexpr>
    RecursionError: maximum recursion depth exceeded while calling a Python object
   $

It seems to me that openpyxl doesn't like it to get compiled: When compiling the same code as you I get:

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

However, there are other Modules for reading excel files like pyexcel (Haven't tried it though)

Another quite simple solution is to use the "xlrd" package instead of "openpyxl". It worked out very well for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM