【问题标题】:PyInstaller - ImportError: No module named _bootlocalePyInstaller - ImportError:没有名为 _bootlocale 的模块
【发布时间】:2021-06-10 12:22:23
【问题描述】:

每次我尝试在 PyInstaller 中编译 python 文件时都会返回很多错误。

这些是编译的错误...

Traceback (most recent call last):
  File "c:\users\Person\appdata\local\programs\python\python310\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\Persong\appdata\local\programs\python\python310\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Person\AppData\Local\Programs\Python\Python310\Scripts\pyinstaller.exe\__main__.py", line 7, in <mo
dule>
  File "c:\users\Person\appdata\local\programs\python\python310\lib\site-packages\PyInstaller\__main__.py", line 114
, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\users\Person\appdata\local\programs\python\python310\lib\site-packages\PyInstaller\__main__.py", line 65,
 in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\users\Person\appdata\local\programs\python\python310\lib\site-packages\PyInstaller\building\build_main.py
", line 725, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:\users\Person\appdata\local\programs\python\python310\lib\site-packages\PyInstaller\building\build_main.py
", line 672, in build
    exec(code, spec_namespace)
  File "E:\___Python___\auto.spec", line 6, in <module>
    a = Analysis(['auto.py'],
  File "c:\users\Person\appdata\local\programs\python\python310\lib\site-packages\PyInstaller\building\build_main.py
", line 242, in __init__
    self.__postinit__()
  File "c:\users\Person\appdata\local\programs\python\python310\lib\site-packages\PyInstaller\building\datastruct.py
", line 160, in __postinit__
    self.assemble()
  File "c:\users\Person\appdata\local\programs\python\python310\lib\site-packages\PyInstaller\building\build_main.py
", line 341, in assemble
    self.graph = initialize_modgraph(
  File "c:\users\Person\appdata\local\programs\python\python310\lib\site-packages\PyInstaller\depend\analysis.py", l
ine 799, in initialize_modgraph
    graph = PyiModuleGraph(
  File "c:\users\Person\appdata\local\programs\python\python310\lib\site-packages\PyInstaller\depend\analysis.py", l
ine 120, in __init__
    self._analyze_base_modules()
  File "c:\users\Person\appdata\local\programs\python\python310\lib\site-packages\PyInstaller\depend\analysis.py", l
ine 288, in _analyze_base_modules
    self._base_modules = [mod
  File "c:\users\Person\appdata\local\programs\python\python310\lib\site-packages\PyInstaller\depend\analysis.py", l
ine 290, in <listcomp>
    for mod in self.import_hook(req)]
  File "c:\users\Person\appdata\local\programs\python\python310\lib\site-packages\PyInstaller\lib\modulegraph\module
graph.py", line 1496, in import_hook
    target_package, target_module_partname = self._find_head_package(
  File "c:\users\Person\appdata\local\programs\python\python310\lib\site-packages\PyInstaller\lib\modulegraph\module
graph.py", line 1681, in _find_head_package
    raise ImportError("No module named " + target_package_name)
ImportError: No module named _bootlocale

我关注的主要错误之一如下...

raise ImportError("No module named " + target_package_name)
ImportError: No module named _bootlocale

【问题讨论】:

标签: python compilation pyinstaller


【解决方案1】:

我不知道但从 _bootlocale 解决的其他错误只是卸载 pyinstaller 并使用以下命令重新安装:pip install https://github.com/rokm/pyinstaller/archive/refs/heads/python-3.10.zip

【讨论】:

  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center