运行pyinstaller打包的可执行文件时出现运行时错误'找不到模块'

时间:2019-06-26 12:25:15

标签: python anaconda pyinstaller bpy

我在anaconda环境中运行python 3.7.3。 在无法从pip和conda软件包中使Blender bpy模块工作之后,我从~\Documents\blender-git

中的源代码构建了bpy模块。

我将构建的文件(“ bpy.pyd”,blender“ 2.8”文件夹和所有“ api-ms-win-core ...” dll文件)复制到环境文件夹~\Anaconda3\envs\myenv\中,然后继续编写我的应用程序,该应用程序运行时没有任何错误。

Python应用程序是从Anaconda Prompt的~\Documents\PythonProjects\PolyReduction文件夹中运行的,并已激活conda环境。

我已经尝试使用pyinstaller将这个应用程序打包为可执行文件,方法是在激活conda环境的情况下从Anaconda Prompt运行以下命令。 pyinstaller -i img.ico -F polyreduce.py 可以正确编译。

运行我的应用程序polyreduce.exe时,我得到了

bpy: couldnt find 'scripts/modules', blender probably wont start.
Freestyle: couldn't find 'scripts/freestyle/modules', Freestyle won't work properly.
ModuleNotFoundError: No module named 'bpy_types'
ModuleNotFoundError: No module named 'bpy_types'
ERROR (bpy.rna): C:\Users\raptop\Documents\blender-git\blender\source\blender\python\intern\bpy_rna.c:7053 pyrna_srna_ExternalType: failed to find 'bpy_types' module
ModuleNotFoundError: No module named 'bpy_types'
ModuleNotFoundError: No module named 'bpy_types'
ERROR (bpy.rna): C:\Users\raptop\Documents\blender-git\blender\source\blender\python\intern\bpy_rna.c:7053 pyrna_srna_ExternalType: failed to find 'bpy_types' module
ModuleNotFoundError: No module named 'bpy_types'
ERROR (bpy.rna): C:\Users\raptop\Documents\blender-git\blender\source\blender\python\intern\bpy_rna.c:7053 pyrna_srna_ExternalType: failed to find 'bpy_types' module
ModuleNotFoundError: No module named 'bpy_types'
ERROR (bpy.rna): C:\Users\raptop\Documents\blender-git\blender\source\blender\python\intern\bpy_rna.c:7053 pyrna_srna_ExternalType: failed to find 'bpy_types' module
ModuleNotFoundError: No module named 'bpy_types'
ERROR (bpy.rna): C:\Users\raptop\Documents\blender-git\blender\source\blender\python\intern\bpy_rna.c:7053 pyrna_srna_ExternalType: failed to find 'bpy_types' module
F0626 21:23:53.515146  3064 utilities.cc:322] Check failed: !IsGoogleLoggingInitialized() You called InitGoogleLogging() twice!
*** Check failure stack trace: ***
PS C:\Users\raptop\Documents\PythonProjects\PolyReduction\dist> ./polyreduce.exe
Color management: using fallback mode for management
Color management: Error could not find role data role.
Color management: scene view "Filmic" not found, setting default "Standard".
bpy: couldnt find 'scripts/modules', blender probably wont start.
Freestyle: couldn't find 'scripts/freestyle/modules', Freestyle won't work properly.
ModuleNotFoundError: No module named 'bpy_types'
ModuleNotFoundError: No module named 'bpy_types'
ERROR (bpy.rna): C:\Users\raptop\Documents\blender-git\blender\source\blender\python\intern\bpy_rna.c:7053 pyrna_srna_ExternalType: failed to find 'bpy_types' module
ModuleNotFoundError: No module named 'bpy_types'

这使我感到困惑,因为:

  1. 我认为它将所有依赖项打包到 可执行文件
  2. 它正在绝对路径而不是相对于可执行文件的路径中寻找模块
  3. 似乎在其中寻找依赖关系的绝对路径是 原始源代码回购位置,而不是anaconda环境 我将构建文件复制到甚至构建位置的文件夹 是我从中复制过来的。

我希望通过将所有依赖项并排放置在可执行文件的相对路径中,或者将它们全部打包在可执行文件中来工作。我怎样才能做到这一点?

0 个答案:

没有答案