Pyinstaller numpy。 EXE在运行时引发错误

问题描述 投票:1回答:1

我在运行使用pyinstaller构建的exe文件时遇到以下运行时问题:

Traceback (most recent call last):
  File "astro_scheduler.py", line 8, in <module>
  File "c:\users\nmonte~1\appdata\local\temp\pip-install-k6m_nn\pyinstaller\PyIn
staller\loader\pyimod03_importers.py", line 395, in load_module
  File "source\MainWindow.py", line 5, in <module>
  File "c:\users\nmonte~1\appdata\local\temp\pip-install-k6m_nn\pyinstaller\PyIn
staller\loader\pyimod03_importers.py", line 395, in load_module
  File "source\Commands.py", line 16, in <module>
  File "C:\WORKSP~1\ASTROS~1\dist\ASTRO_~1\astropy\__init__.py", line 116, in <m
odule>
    _check_numpy()
  File "C:\WORKSP~1\ASTROS~1\dist\ASTRO_~1\astropy\__init__.py", line 110, in _c
heck_numpy
    raise ImportError(msg)
ImportError: Numpy version 1.9.0 or later must be installed to use Astropy
[8480] Failed to execute script astro_scheduler

这是我的冻结:

altgraph==0.16.1
astroid==1.6.6
astroplan==0.5
astropy==2.0.16
atomicwrites==1.3.0
attrs==19.2.0
auto-py-to-exe==2.6.5
backports.functools-lru-cache==1.5
bottle==0.12.17
bottle-websocket==0.2.9
certifi==2019.9.11
cffi==1.12.3
chardet==3.0.4
colorama==0.4.1
configparser==4.0.2
dis3==0.1.3
Eel==0.10.4
enum34==1.1.6
funcsigs==1.0.2
future==0.17.1
futures==3.3.0
gevent==1.4.0
gevent-websocket==0.10.1
greenlet==0.4.15
idna==2.8
iso8601==0.1.12
isort==4.3.21
lazy-object-proxy==1.4.2
macholib==1.11
mccabe==0.6.1
modulegraph==0.17
more-itertools==5.0.0
numpy==1.16.5
pefile==2019.4.18
pluggy==0.7.1
psutil==5.6.3
py==1.8.0
pycparser==2.19
pyfits==3.5
PyInstaller==3.5
PyInstaller-Hooks==20191003
pylint==1.9.5
PyPubSub==3.3.0
pytest==3.6.4
pytz==2019.3
pywin32==225
pywin32-ctypes==0.2.0
PyYAML==5.1.2
requests==2.22.0
serial==0.0.97
singledispatch==3.4.0.3
six==1.12.0
urllib3==1.25.6
whichcraft==0.6.1
wrapt==1.11.2

这是pyinstaller的输出:

102 INFO: PyInstaller: 3.5
103 INFO: Python: 2.7.16
103 INFO: Platform: Windows-7-6.1.7601-SP1
105 INFO: UPX is not available.
569 INFO: Extending PYTHONPATH with paths
['C:\\workspace\\astroscheduler', 'C:\\workspace\\astroscheduler']
570 INFO: checking Analysis
570 INFO: Building Analysis because Analysis-00.toc is non existent
572 INFO: Initializing module dependency graph...
575 INFO: Initializing module graph hooks...
639 INFO: running Analysis Analysis-00.toc
661 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
  required by c:\python27\python.exe
1026 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1
fc8b3b9a1e18e3b_9.0.21022.8_none_60a5df56e60dc5df.manifest
1029 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1
fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest
1030 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1
fc8b3b9a1e18e3b_9.0.30729.4940_none_f47ed0f6f6564d90.manifest
1032 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1
fc8b3b9a1e18e3b_9.0.30729.6161_none_f480bfaef65491a5.manifest
1422 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30
729.6161_none ...
1424 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc
8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57.manifest
1425 INFO: Searching for file msvcr90.dll
1427 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_
9.0.30729.6161_none_50934f2ebcb7eb57\msvcr90.dll
1427 INFO: Searching for file msvcp90.dll
1427 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_
9.0.30729.6161_none_50934f2ebcb7eb57\msvcp90.dll
1428 INFO: Searching for file msvcm90.dll
1428 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_
9.0.30729.6161_none_50934f2ebcb7eb57\msvcm90.dll
1786 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1
fc8b3b9a1e18e3b_9.0.21022.8_none_60a5df56e60dc5df.manifest
1787 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1
fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest
1789 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1
fc8b3b9a1e18e3b_9.0.30729.4940_none_f47ed0f6f6564d90.manifest
1790 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1
fc8b3b9a1e18e3b_9.0.30729.6161_none_f480bfaef65491a5.manifest
1792 INFO: Adding redirect Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0,
 30729, 6161)
1829 INFO: Caching module hooks...
1836 INFO: Analyzing astro_scheduler.py
5520 INFO: Processing pre-safe import module hook   _xmlplus
5680 INFO: Processing pre-safe import module hook   win32com
5718 INFO: Processing pre-find module path hook   distutils
10351 INFO: Processing pre-safe import module hook   urllib3.packages.six.moves
12109 INFO: Loading module hooks...
12109 INFO: Loading module hook "hook-distutils.py"...
12111 INFO: Loading module hook "hook-sysconfig.py"...
12111 INFO: Loading module hook "hook-xml.py"...
12210 INFO: Loading module hook "hook-httplib.py"...
12210 INFO: Loading module hook "hook-encodings.py"...
12733 INFO: Loading module hook "hook-_tkinter.py"...
12849 INFO: checking Tree
12849 INFO: Building Tree because Tree-00.toc is non existent
12849 INFO: Building Tree Tree-00.toc
13011 INFO: checking Tree
13011 INFO: Building Tree because Tree-01.toc is non existent
13013 INFO: Building Tree Tree-01.toc
13030 INFO: Loading module hook "hook-pubsub.core.py"...
Traceback (most recent call last):
  File "<string>", line 41, in <module>
  File "<string>", line 36, in walk_packages
  File "<string>", line 20, in walk_packages
  File "c:\python27\lib\site-packages\pubsub\core\arg1\__init__.py", line 16, in
 <module>
    raise RuntimeError(msg)
RuntimeError: Should not import this directly, used by pubsub.core if applicable

13182 INFO: Loading module hook "hook-certifi.py"...
13184 INFO: Loading module hook "hook-pywintypes.py"...
13530 INFO: Loading module hook "hook-win32com.py"...
13626 INFO: Loading module hook "hook-pythoncom.py"...
13990 INFO: Looking for ctypes DLLs
14026 INFO: Analyzing run-time hooks ...
14032 INFO: Including run-time hook 'pyi_rth__tkinter.py'
14033 INFO: Including run-time hook 'pyi_rth_certifi.py'
14034 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
14045 INFO: Looking for dynamic libraries
14519 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.mfc_
1fc8b3b9a1e18e3b_9.0.21022.8_none_5926f98ceadc42c2.manifest
14520 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.mfc_
1fc8b3b9a1e18e3b_9.0.30729.6161_none_ed01d9e4fb230e88.manifest
14872 INFO: Searching for assembly x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.3
0729.6161_none ...
14872 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.mfc_1f
c8b3b9a1e18e3b_9.0.30729.6161_none_4bf7e3e2bf9ada4c.manifest
14875 INFO: Searching for file mfc90.dll
14875 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b
_9.0.30729.6161_none_4bf7e3e2bf9ada4c\mfc90.dll
14875 INFO: Searching for file mfc90u.dll
14875 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b
_9.0.30729.6161_none_4bf7e3e2bf9ada4c\mfc90u.dll
14875 INFO: Searching for file mfcm90.dll
14875 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b
_9.0.30729.6161_none_4bf7e3e2bf9ada4c\mfcm90.dll
14875 INFO: Searching for file mfcm90u.dll
14875 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b
_9.0.30729.6161_none_4bf7e3e2bf9ada4c\mfcm90u.dll
15261 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.mfc_
1fc8b3b9a1e18e3b_9.0.21022.8_none_5926f98ceadc42c2.manifest
15263 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.mfc_
1fc8b3b9a1e18e3b_9.0.30729.6161_none_ed01d9e4fb230e88.manifest
15263 INFO: Adding redirect Microsoft.VC90.MFC version (9, 0, 21022, 8) -> (9, 0
, 30729, 6161)
15792 INFO: Looking for eggs
15792 INFO: Using Python library C:\Windows\system32\python27.dll
15792 INFO: Found binding redirects:
[BindingRedirect(name=u'Microsoft.VC90.MFC', language=None, arch=u'x86', oldVers
ion=(9, 0, 21022, 8), newVersion=(9, 0, 30729, 6161), publicKeyToken=u'1fc8b3b9a
1e18e3b'), BindingRedirect(name=u'Microsoft.VC90.CRT', language=None, arch=u'x86
', oldVersion=(9, 0, 21022, 8), newVersion=(9, 0, 30729, 6161), publicKeyToken=u
'1fc8b3b9a1e18e3b')]
15799 INFO: Warnings written to C:\workspace\astroscheduler\build\astro_schedule
r\warn-astro_scheduler.txt
15875 INFO: Graph cross-reference written to C:\workspace\astroscheduler\build\a
stro_scheduler\xref-astro_scheduler.html
16134 INFO: Appending 'datas' from .spec
16272 INFO: checking PYZ
16273 INFO: Building PYZ because PYZ-00.toc is non existent
16273 INFO: Building PYZ (ZlibArchive) C:\workspace\astroscheduler\build\astro_s
cheduler\PYZ-00.pyz
17579 INFO: Building PYZ (ZlibArchive) C:\workspace\astroscheduler\build\astro_s
cheduler\PYZ-00.pyz completed successfully.
17674 INFO: checking PKG
17674 INFO: Building PKG because PKG-00.toc is non existent
17675 INFO: Building PKG (CArchive) PKG-00.pkg
17695 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
17700 INFO: Bootloader c:\python27\lib\site-packages\PyInstaller\bootloader\Wind
ows-32bit\run.exe
17700 INFO: checking EXE
17700 INFO: Building EXE because EXE-00.toc is non existent
17700 INFO: Building EXE from EXE-00.toc
17700 INFO: Appending archive to EXE C:\workspace\astroscheduler\build\astro_sch
eduler\astro_scheduler.exe
17704 INFO: Building EXE from EXE-00.toc completed successfully.
17714 INFO: checking COLLECT
17715 INFO: Building COLLECT because COLLECT-00.toc is non existent
17715 INFO: Building COLLECT COLLECT-00.toc
17756 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30
729, 6161)
22865 INFO: Building COLLECT COLLECT-00.toc completed successfully.

这是我正在使用的.spec文件:

import astropy
block_cipher = None
astropy_path, = astropy.__path__

a = Analysis(['astro_scheduler.py'],
             pathex=['C:\\workspace\\astroscheduler'],
             binaries=[],
             datas=[(astropy_path, 'astropy')],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=['astropy'],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='astro_scheduler',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               upx_exclude=[],
               name='astro_scheduler')

非常感谢您的帮助。我在StackOverflow和其他站点上搜索了类似的问题,但似乎都无法解决我的问题。

python numpy pyinstaller astropy
1个回答
0
投票

尝试安装并使用pyInstaller 3.4版本。因为在numpy和pyinstaller 3.5版本中工作时我也遇到了numpy错误

© www.soinside.com 2019 - 2024. All rights reserved.