我有一个大程序正在尝试与pyinstaller打包,并且发现问题是openpyxl包。

这是一个最小程序:

import openpyxl
print("Hello World")


这是我用来运行pyinstaller的命令:

$ pyinstaller --onefile demo2.py


这是输出:

$ 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
   $

最佳答案

在我看来,openpyxl不喜欢它进行编译:
当编译与您相同的代码时,我得到:

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

但是,还有其他模块可用于读取pyexcel等excel文件(尽管没有尝试过)

关于python - pyinstaller 3.3.1不适用于openpyxl 2.4.1,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52724954/

10-16 10:58