python 使用pyinstaller后无法创建csv文件

vddsk6oq  于 2023-02-21  发布在  Python
关注(0)|答案(1)|浏览(165)

使用pyinstaller将以下代码转换为.exe后,使用dist-folder中的.exe后,程序无法将csv文件从dict data = {}写入输出路径data_path_out
我以前尝试过将我的python文件链接到test.lnk,效果很好。https://i.stack.imgur.com/ow7mo.png

import os
from os.path import join, dirname
import pathlib
import csv

data_path_in = pathlib.Path(join(dirname(__file__), "00_Data"))
data_path_out = pathlib.Path(join(dirname(__file__), "01_Results"))

data = {}

with open(join(data_path_in, "Data.txt"), "r") as csv_file:
    r = csv.reader(csv_file, delimiter= ",")
    
    for row in r:
        data[row[0]] = row[1]
        
        
with open(join(data_path_out, "Results.txt"), "w") as csv_file:
    wr = csv.writer(csv_file, dialect = "excel")
    for key, value in data.items():
        wr.writerow([key, value])
jdgnovmf

jdgnovmf1#

正如评论中提到的,用Pyinstaller转换的应用程序通常被视为病毒,你可以尝试使用Nuitka

相关问题