Pyinstaller - 无法从 UTF-8 解码 wchar_t(fopen:没有这样的文件或目录)

Pyinstaller - Failed to decode wchar_t from UTF-8 (fopen: no such file or directory)

所以我看了很多关于 SO 的答案,但我似乎无法理解可能发生的事情。在使用 pyinstaller 创建一个 exe(并将其移动到具有依赖项的目录)之后,我得到了这个晦涩的错误:

Failed to decode wchar_t from UTF-8
MultiByteToWideChar: The data area passed to a system call is too small.
share\jupyter\lab\staging\node_modules\.cache\terser-webpack-plugin\content-v2\sha512e\ba\cfce62ec1f408830c0335f2b46219d58ee5b068473e7328690e542d2f92f2058865c600d845a2e404e282645529eb0322aa4429a84e189eb6b58c1b97c1a could not be extracted!
fopen: No such file or directory 

此处只有一个文件依赖项,即定义历史销售额时的发票文件(不确定是否使用绝对字符串是导致此处问题的原因)。我也不记得解码过任何东西,所以我对如何修复这个错误感到很困惑(我也不知道 jupyter lab 与我的 python 脚本有什么关系——它最初是从笔记本转换而来的,但我不认为这会很重要)。

我编译的代码如下(出于安全原因,我有意删除了 cnxn 细节,但代码在任何 IDE 中都可以正常执行)。请原谅我的代码有点草率(我是菜鸟):

#!/usr/bin/env python
# coding: utf-8
running = True

# 2376 is a valid order number

while running:
    import pandas as pd
    
    import pyodbc 
    cnxn = pyodbc.connect("")
    
    
    pd.set_option('display.max_columns', None)
    
    design = ""
    order = ""

    while True:
        design_or_order = input("Do you wish to check an individual design (D) or an order (O): ")
        if design_or_order not in ["D","O"]:
            print("Type either an O or a D")
        else:
            break

    if design_or_order == "D":
        
        customers = pd.read_sql_query('select ACCOUNT from CUSTOMER', cnxn).convert_dtypes()
        customers = customers.ACCOUNT.to_list()

        inventory = pd.read_sql_query("select DESIGN from STCKHEAD", cnxn).convert_dtypes()            
        inventory = inventory.DESIGN.to_list()
        
        while True:
            account = input("Enter Account Code:")

            if account not in customers:
                print("Please enter a valid account code")
            else:
                break
        while True:
            design = [input("Enter Design Code:")]
            if design[0] not in inventory:
                print("Please enter a valid design code")
            else:
                break

    else:
        process_orders = pd.read_sql_query("select ORDERNUM from OrderExportView where STAGE = 'B'", cnxn).convert_dtypes()
        process_orders = process_orders.ORDERNUM.to_list()
        #print(process_orders)
        
        while True:
            try:
                order = int(input("Enter Order Number:"))
            except ValueError:
                print ("Please enter an Integer")
            else:
                if order not in process_orders:
                    print("Please enter a valid (scan pack) order number")
                else:
                    break

解决了。

基本上查看了日志文件并意识到我只需要做

pyinstaller --exclude-module IPython --onefile "filename"

使其正常工作(Pandas 引入了 IPython,后者引入了导致问题的 jupyter 实验室)。

这个 SO 问题帮助了我: Pyinstaller failed to import scipy.signals