简体   繁体   English

Pyinstaller 没有名为 msvc 的模块

[英]Pyinstaller No module named msvc

I am using Pyinstaller on Ubuntu to create a binary executable for my Python code.我在 Ubuntu 上使用 Pyinstaller 为我的 Python 代码创建二进制可执行文件。 This code has a bunch of files and dependencies.这段代码有一堆文件和依赖项。 One of them is tensorflow .其中之一是tensorflow The executable is getting created correctly but when I try to run it, I get the following error:可执行文件已正确创建,但是当我尝试运行它时,出现以下错误:

Traceback (most recent call last):
  File "detection_init.py", line 14, in <module>
    import lib.tensorboxDetector as tensorboxDetector
  File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
  File "lib/tensorboxDetector.py", line 20, in <module>
    import tensorflow as tf
  File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
  File "tensorflow/__init__.py", line 24, in <module>
  File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
  File "tensorflow/python/__init__.py", line 104, in <module>
  File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
  File "tensorflow/python/platform/test.py", line 57, in <module>
  File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
  File "mock/__init__.py", line 2, in <module>
  File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
  File "mock/mock.py", line 71, in <module>
  File "pbr/version.py", line 461, in semantic_version
  File "pbr/version.py", line 447, in _get_version_from_pkg_resources
  File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
  File "pbr/packaging.py", line 32, in <module>
  File "/tmp/pip-build-EuLWEf/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
  File "setuptools/__init__.py", line 160, in <module>
  File "setuptools/monkey.py", line 104, in patch_all
  File "setuptools/monkey.py", line 156, in patch_for_msvc_specialized_compiler
  File "importlib/__init__.py", line 37, in import_module
ImportError: No module named msvc

How can I resolve this error and run the file correctly?如何解决此错误并正确运行文件?

I added msvc to the hidden imports.我将msvc添加到隐藏的导入中。 I'm still battling imports, but seem to be past this one.我仍在与进口作斗争,但似乎已经过了这一关。

{
    a = Analysis(['/Users/Ben/Documents/DeepMeerkat/DeepMeerkat/main.py'],
                 pathex=['/Users/ben/Documents/DeepMeerkat/DeepMeerkat/'],
                 binaries=[],
                 datas=[],
                 hiddenimports=['setuptools.msvc'],
                 hookspath=[],
                 runtime_hooks=[],
                 excludes=[ 'enchant', 'twisted'],
                 win_no_prefer_redirects=False,
                 win_private_assemblies=False,
                 cipher=block_cipher)
}

This problem was solved by using the dev version of Pyinstaller.这个问题是通过使用开发版的 Pyinstaller 解决的。 More details here: https://github.com/pyinstaller/pyinstaller/issues/2824更多细节在这里: https : //github.com/pyinstaller/pyinstaller/issues/2824

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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