exe已停止工作怎么解决?_pyinstaller 打包exe出现no such file 问题怎么解决?

编程新手在使用Python 3.6和PyInstaller 3.6打包程序时遇到exe无法执行的问题,错误提示为'Failed to execute script wlcoud'和'FileNotFoundError: [Errno 2] No such file or directory'。尝试了多种网上的解决办法无效,且在升级到Python 3.8和Pyinstaller 4.0后问题依然存在。附件中包含错误截图。
摘要由CSDN通过智能技术生成

编程纯小白的我在学习python过程中,尝试使用pyinstaller 打包后的exe一直执行不了,提示Failed to execute script wlcoud,尝试在网上找了很多方法,都解决不了

使用Debug模式抓取失败原因为FileNotFoundError:[Errno 2]No such file or directory.错误截图如下:(其中每次运行exe时找不到的文件的路径下,的._MEI1215402这个文件数字会一直变动)

7829751460c70c995fbc405ac9fad38b.png

执行环境为:python3.6,pyinstaller3.6

63dfcfbe5505a287a14d2ea8addf1f32.png

使用python3.8或者pyinstaller4.0都是这个错误,请教下各位大佬,这个问题应该怎么解决?

代码如下

# 导入相关库
from pandas import Series 
from jieba import lcut 
from wordcloud import WordCloud
from matplotlib.pyplot import figure,imshow,axis, show 
from time import localtime,strftime
from imageio import imread

import configparser
import os



filepath = os.getcwd()
#增加配置文件
def config_parser(cfgpr):
    #如果没有配置文件则自动生成
    config = configparser.ConfigParser()
    if not os.path.exists(os.path.join(filepath,cfgpr)):
        config['Sys']={}        
        config['Sys']['BasicTxt'] = 'test.txt'      
        config['Sys']['DelTxt'] = 'stoplist.txt'       
        config['Sys']['BGP'] = 'test.jpg'
        config['Sys']['maxword'] = '2000'
        config['Sys']['maxfontsize'] = '96'
        with open (os.path.join(filepath,cfgpr),'w') as f:
            config.write(f)             
  
try:
    
    config_parser(os.path.join(filepath,'config.cfg')) 
    config = configparser.ConfigParser()

    config.read(os.path.join(filepath,'config.cfg'))#读取配置文件,并提取需要的信息
    BasicTxt  = os.path.join(filepath,config['Sys']['BasicTxt'])
    DelTxt  = os.path.join(filepath,config['Sys']['DelTxt'])
    Bgp  = os.path.join(filepath,config['Sys']['Bgp'])
    maxword  = int(config['Sys']['maxword'])
    maxfontsize  = int(config['Sys']['maxfontsize'])



# 读取文本文件
    with open(BasicTxt,encoding="utf-8") as f:
        txt = f.read()
    txt = txt.split()
    data_cut = [lcut(x) for x in txt]
    data_cut
# 读取停用词
    with open(DelTxt,encoding="utf-8") as f:
        stop = f.read()
    stop = stop.split()
    stop = [" "] + stop
# 去掉停用词之后的最终词
    s_data_cut = Series(data_cut)
    all_words_after = s_data_cut.apply(lambda x:[i for i in x if i not in stop])
# 词频统计
    all_words = []
    for i in all_words_after:
        all_words.extend(i)
    word_count = Series(all_words).value_counts()
# 词云图的绘制
    # 1)读取背景图片
    back_picture = imread(Bgp)

    # 2)设置词云参数
    wc = WordCloud(font_path="simhei.ttf",
                background_color="white",
                max_words=maxword,
                mask=back_picture,
                max_font_size=maxfontsize,
                random_state=52
                )
    wc2 = wc.fit_words(word_count) 

    figure(figsize=(16,8))
    imshow(wc2)
    axis("off")
    show()
    wc2.to_file(os.path.join(filepath,"test.png"))
except Exception as e:    
    a = str(e)
    with open(os.path.join(filepath,'faild.txt'),'w') as f:
        f.write('[{}] {}'.format(strftime("%Y-%m-%d %H:%M:%S",localtime()),a))
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值