python - Pyinstaller Tkinter hiddenimports = [sysconfig._get_sysconfigdata_name()] 错误

标签 python python-3.x tkinter pyinstaller

当我尝试使用 pyinstaller 将我的 .py 文件转换为应用程序时,我在终端上得到以下输出

Rishabhs-MacBook-Pro:desktop rishabhtatia$ pyinstaller --clean --hidden-
import tkinter test.py
697 INFO: PyInstaller: 3.3.1
697 INFO: Python: 3.6.4
709 INFO: Platform: Darwin-17.4.0-x86_64-i386-64bit
711 INFO: wrote /Users/rishabhtatia/Desktop/test.spec
714 INFO: UPX is not available.
716 INFO: Removing temporary files and cleaning cache in /Users/rishabhtatia/Library/Application Support/pyinstaller
Traceback (most recent call last):
  File "/Users/rishabhtatia/anaconda3/bin/pyinstaller", line 11, in <module>
    sys.exit(run())
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/__main__.py", line 94, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/__main__.py", line 46, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 791, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 737, in build
    exec(text, spec_namespace)
  File "<string>", line 16, in <module>
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 162, in __init__
    raise ValueError("script '%s' not found" % script)
ValueError: script '/Users/rishabhtatia/Desktop/test.py' not found
Rishabhs-MacBook-Pro:desktop rishabhtatia$ pyinstaller --clean --hidden-import tkinter typeMachine.py
314 INFO: PyInstaller: 3.3.1
314 INFO: Python: 3.6.4
321 INFO: Platform: Darwin-17.4.0-x86_64-i386-64bit
323 INFO: wrote /Users/rishabhtatia/Desktop/typeMachine.spec
326 INFO: UPX is not available.
327 INFO: Removing temporary files and cleaning cache in /Users/rishabhtatia/Library/Application Support/pyinstaller
328 INFO: Extending PYTHONPATH with paths
['/Users/rishabhtatia/Desktop', '/Users/rishabhtatia/Desktop']
328 INFO: checking Analysis
328 INFO: Building Analysis because out00-Analysis.toc is non existent
328 INFO: Initializing module dependency graph...
332 INFO: Initializing module graph hooks...
334 INFO: Analyzing base_library.zip ...
4406 INFO: Analyzing hidden import 'tkinter'
4576 INFO: running Analysis out00-Analysis.toc
4586 INFO: Caching module hooks...
4590 INFO: Analyzing /Users/rishabhtatia/Desktop/typeMachine.py
4827 INFO: Processing pre-safe import module hook   six.moves
5525 INFO: Processing pre-find module path hook   distutils
10217 INFO: Processing pre-find module path hook   site
10218 INFO: site: retargeting to fake-dir '/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/fake-modules'
16738 INFO: Loading module hooks...
16738 INFO: Loading module hook "hook-pkg_resources.py"...
17122 INFO: Processing pre-safe import module hook   win32com
17433 INFO: Loading module hook "hook-PyQt5.py"...
17628 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
17630 INFO: Loading module hook "hook-lib2to3.py"...
17633 INFO: Loading module hook "hook-_tkinter.py"...
17877 INFO: checking Tree
17877 INFO: Building Tree because out00-Tree.toc is non existent
17877 INFO: Building Tree out00-Tree.toc
17888 INFO: checking Tree
17888 INFO: Building Tree because out01-Tree.toc is non existent
17889 INFO: Building Tree out01-Tree.toc
17895 INFO: Loading module hook "hook-encodings.py"...
17973 INFO: Loading module hook "hook-PIL.py"...
17979 INFO: Excluding import 'PyQt4'
17981 INFO:   Removing import of PyQt4 from module PIL.ImageQt
17981 INFO: Excluding import 'PySide'
17983 INFO:   Removing import of PySide from module PIL.ImageQt
17983 INFO: Excluding import 'tkinter'
17985 INFO: Import to be excluded not found: 'FixTk'
17985 INFO: Excluding import 'PyQt5'
17987 INFO:   Removing import of PyQt5.QtCore from module PIL.ImageQt
17987 INFO:   Removing import of PyQt5.QtGui from module PIL.ImageQt
17987 INFO: Loading module hook "hook-setuptools.py"...
18020 INFO: Loading module hook "hook-pycparser.py"...
18279 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
18847 INFO: Loading module hook "hook-PIL.Image.py"...
19267 INFO: Loading module hook "hook-PyQt5.Qt.py"...
19269 INFO: Loading module hook "hook-pytest.py"...
20348 INFO: Loading module hook "hook-PyQt5.QtWidgets.py"...
20349 INFO: Loading module hook "hook-sysconfig.py"...
Traceback (most recent call last):
  File "/Users/rishabhtatia/anaconda3/bin/pyinstaller", line 11, in <module>
    sys.exit(run())
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/__main__.py", line 94, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/__main__.py", line 46, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 791, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 737, in build
    exec(text, spec_namespace)
  File "<string>", line 16, in <module>
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 213, in __init__
    self.__postinit__()
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/datastruct.py", line 161, in __postinit__
    self.assemble()
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 472, in assemble
    module_hook.post_graph()
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/imphook.py", line 410, in post_graph
    self._load_hook_module()
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/imphook.py", line 377, in _load_hook_module
    self.hook_module_name, self.hook_filename)
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/compat.py", line 744, in importlib_load_source
    return mod_loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 823, in load_module
  File "<frozen importlib._bootstrap_external>", line 682, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 684, in _load
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/hooks/hook-sysconfig.py", line 42, in <module>
    hiddenimports = [sysconfig._get_sysconfigdata_name()]
TypeError: _get_sysconfigdata_name() missing 1 required positional argument: 'check_exists'

我尝试过对 pyinstaller 使用各种不同的命令,并尝试使用 py2app 但没有成功。

我目前正在使用 python 版本:3.6.4 Anaconda 版本:1.6.9 macOS HighSierra

任何有关如何将此 python 文件成功转换为应用程序的帮助都将不胜感激!谢谢!

最佳答案

我遇到了同样的问题。经过进一步调查,这似乎是 Anaconda 引入重大更改的问题。

Please get in touch with the anaconda people then. We can not support their distribution any longer if they add incompatible changes.

I had the same issue before, changing the conda environment's python to 3.5.1 removed that error.

I had the same error (with anaconda as well), but only with python version 3.6.4. If I downgrade to 3.6.3, the error disappears.

If you experience this issue, update your conda installation. If this does not help, get in touch with the anaconda people. We can not support their distribution any longer if they add incompatible changes.

参见 https://github.com/pyinstaller/pyinstaller/issues/3192进行全面讨论。

关于python - Pyinstaller Tkinter hiddenimports = [sysconfig._get_sysconfigdata_name()] 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49624213/

相关文章:

Python 正则表达式 AttributeError : 'NoneType' object has no attribute 'group'

python - 在python中更新字典

Python pandas 基于两列的分组进行排名/排序,每个输入都不同

python - 使用 Python 检查项目是否在字典中并且为真

python - 鼠标事件中的 tkinter wait_variable

python - 更改 Tkinter 列表框选择时获取回调?

python - 不确定 'and' 操作

python-3.x - 如何使用 Gekko 释放变量

python - 如何为可以发送和接收消息的mqtt客户端实现多线程

python - Tkinter 和 Tic-Tac-Toe 的问题