如何在不使用pyinstaller的情况下使用spacy为python程序创建exe文件?

如何在不使用pyinstaller的情况下使用spacy为python程序创建exe文件?,python,pyinstaller,spacy,Python,Pyinstaller,Spacy,我正在尝试打包包含spacy的Python程序。我使用隐藏导入尝试pyinstaller,并创建了一个exe文件。但我总是会遇到以下错误: "FileNotFoundError: [Errno 2] No such file or directory: \\AppData\\Local\\Temp\\_MEI66162\\thinc\\neural\\_custom_kernels.cu'". 请帮我解决这个问题,或者告诉我是否有其他方法来创建包文件 Python : 3.7.0 Spacy

我正在尝试打包包含spacy的Python程序。我使用隐藏导入尝试pyinstaller,并创建了一个exe文件。但我总是会遇到以下错误:

 "FileNotFoundError: [Errno 2] No such file or directory: \\AppData\\Local\\Temp\\_MEI66162\\thinc\\neural\\_custom_kernels.cu'".
请帮我解决这个问题,或者告诉我是否有其他方法来创建包文件

Python : 3.7.0
Spacy: 2.2.3

我遇到了完全相同的问题,最终我放弃了spacy并将其回滚到2.2.1版,不知何故,我能够在pyinstaller上编译我的程序而没有任何问题

pip install spacy==2.2.1

你试过附加的钩子和扩展路径吗?请参阅下面的链接

它对我来说是在一个正常的环境中工作的(不是虚拟环境)

FileNotFound错误是因为PyInstaller没有正确打包thinc;thinc需要一个钩子。我发现,包含spacy import*的as脚本将与下面的钩子文件一起工作。我使用的命令是:

pyinstaller test-spacy.py——附加挂钩dir=

只需将下面的文本复制到一个名为hook-spacy.py的文件中,该文件与脚本位于同一目录中

# HOOK FILE FOR SPACY
from PyInstaller.utils.hooks import collect_all

# ----------------------------- SPACY -----------------------------
data = collect_all('spacy')

datas = data[0]
binaries = data[1]
hiddenimports = data[2]

# ----------------------------- THINC -----------------------------
data = collect_all('thinc')

datas += data[0]
binaries += data[1]
hiddenimports += data[2]

# ----------------------------- CYMEM -----------------------------
data = collect_all('cymem')

datas += data[0]
binaries += data[1]
hiddenimports += data[2]

# ----------------------------- PRESHED -----------------------------
data = collect_all('preshed')

datas += data[0]
binaries += data[1]
hiddenimports += data[2]

# ----------------------------- BLIS -----------------------------

data = collect_all('blis')

datas += data[0]
binaries += data[1]
hiddenimports += data[2]
# This hook file is a bit of a hack - really, all of the libraries should be in seperate hook files. (Eg hook-blis.py with the blis part of the hook)
还可以调整.spec文件,并添加main.spec文件和以下详细信息,并且可以正常工作

# -*- mode: python ; coding: utf-8 -*-

import PyInstaller

datas = []
datas.extend(PyInstaller.utils.hooks.collect_data_files('spacy.lang', include_py_files = True))
datas.extend(PyInstaller.utils.hooks.collect_data_files('thinc'))

block_cipher = None
a = Analysis(['main.py'],
         pathex=['D:\\rajesh\\python\\console\\live'],
         binaries=[],
         datas=datas,
         hiddenimports = [
            'spacy.kb',
            'spacy.lexeme',
            'spacy.matcher._schemas',
            'spacy.morphology',
            'spacy.parts_of_speech',
            'spacy.syntax._beam_utils',
            'spacy.syntax._parser_model',
            'spacy.syntax.arc_eager',
            'spacy.syntax.ner',
            'spacy.syntax.nn_parser',
            'spacy.syntax.stateclass',
            'spacy.syntax.transition_system',
            'spacy.tokens._retokenize',
            'spacy.tokens.morphanalysis',
            'spacy.tokens.underscore',

            'spacy._align',

            'blis',
            'blis.py',

            'cymem',
            'cymem.cymem',

            'murmurhash',
            'murmurhash.mrmr',

            'preshed.maps',

            'srsly.msgpack.util',

            'thinc.extra.search',
            'thinc.linalg',
            'thinc.neural._aligned_alloc',
            'thinc.neural._custom_kernels',

            'sklearn.utils._cython_blas',
            'sklearn.neighbors.typedefs',
            'sklearn.neighbors.quad_tree',
            'sklearn.tree._utils'
        ],
         hookspath=[],
         runtime_hooks=[],
         excludes=[],
         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='main',
      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='main')

你的setup.py看起来怎么样?我没有使用任何安装文件。。我已经为其他程序创建了exe文件。。。