第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

python中的程序用pyinstaller打包后無(wú)法運(yùn)行

python中的程序用pyinstaller打包后無(wú)法運(yùn)行

慕桂英3389331 2023-08-08 16:42:42
我的程序(.py)在 vscode 平臺(tái)上完美運(yùn)行。然而,用pyinstaller打包成.exe文件后,似乎不起作用。錯(cuò)誤消息是“ModuleNotFoundError:沒有名為plotly.validators.scatter的模塊” 這是我的代碼“氣泡圖”:# Bubble Diagram Version3.0import tkinter as tkimport tkinter.filedialog as fdimport plotly as pyimport plotly.graph_objs as goimport openpyxlimport pandas as pdimport osclass App(tk.Tk):    def __init__(self):        super().__init__()        self.path1 = fd.StringVar()        self.path2 = fd.StringVar()        self.name_input = fd.StringVar()        group_1 = tk.LabelFrame(self, padx=15, pady=10,                                text="Input and Output Settings")        group_1.pack(padx=10, pady=5)        tk.Label(group_1, text='Step1').grid(row=0, column=0)        tk.Button(group_1, text="Import data from", bg='green',                  width=20, command=self.choose_file).grid(row=0, column=1)        tk.Label(group_1, textvariable=self.path1, width=40, bg='grey', fg='white').grid(row=0, column=2, pady=5)        tk.Label(group_1, text='Step2').grid(row=1, column=0)        tk.Button(group_1, text="Set output path", bg='orange',                  width=20, command=self.choose_directory).grid(row=1, column=1)        tk.Label(group_1, textvariable=self.path2, width=40, bg='grey', fg='white').grid(row=1, column=2, pady=5)        tk.Label(group_1, text='Step3').grid(row=2, column=0)        tk.Label(group_1, text='Input name WITHOUT suffix', bg='SteelBlue', width=20).grid(row=2, column=1)        tk.Entry(group_1, textvariable=self.name_input, bg='grey', width=40).grid(row=2, column=2)        group_2 = tk.LabelFrame(self, padx=15, pady=10, text="Implementation")        group_2.pack(padx=10, pady=5)        tk.Label(group_2, text='Step4').grid(row=0, column=0)        tk.Button(group_2, text="Start to plot", bg='red',                  width=10, command=self.start).grid(row=0, column=1)            ),我應(yīng)該怎么做才能解決問題?謝謝
查看完整描述

1 回答

?
慕姐8265434

TA貢獻(xiàn)1813條經(jīng)驗(yàn) 獲得超2個(gè)贊

那么你還在為此苦苦掙扎嗎?


您需要更新規(guī)范文件的“data”和“hiddenimports”部分,以確保庫(kù)被導(dǎo)入。我在下面向您展示了我的(效果很好)。您需要修改它以包含 openpyxl、tkinter 和 pandas。


a = Analysis(['main.py'],

             pathex=['C:\\Users\\user\\PycharmProjects\\PlotlyExample'],

             binaries=[],

             datas=[('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\plotly\\', 'plotly'),

             ('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\kaleido\\', 'kaleido'),

             ('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\pptx\\', 'pptx'),],

             hiddenimports=['pandas','numpy','plotly','pptx'],

             hookspath=[],

             runtime_hooks=[],

             excludes=[],

             win_no_prefer_redirects=False,

             win_private_assemblies=False,

             cipher=block_cipher,

             noarchive=False)

實(shí)際上,我遇到了與您關(guān)于plotly.json 相同的錯(cuò)誤,所以我知道上述解決方案有效。:)


同樣重要的是,如果您要導(dǎo)出靜態(tài)圖像,請(qǐng)?jiān)谝?guī)范文件中包含 Kaleido 或 Orcas。我正在使用 Kaleido,因此您可以在我的規(guī)范文件設(shè)置中看到它。


然后通過以下方式運(yùn)行 PyInstaller: pyinstaller main.spec --clean


其中 main.spec 是您的規(guī)范文件(更改名稱)。


編輯:為了讓事情變得更容易,這是我的整個(gè)規(guī)范文件:


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

# Command to compile the spec and python files

# pyinstaller main.spec --clean --onefile


block_cipher = None



a = Analysis(['main.py'],

             pathex=['C:\\Users\\user\\PycharmProjects\\PlotlyExample'],

             binaries=[],

             datas=[('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\plotly\\', 'plotly'),

             ('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\kaleido\\', 'kaleido'),

             ('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\pptx\\', 'pptx'),],

             hiddenimports=['pandas','numpy','plotly','pptx'],

             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')


查看完整回答
反對(duì) 回復(fù) 2023-08-08
  • 1 回答
  • 0 關(guān)注
  • 332 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)