zly1533535226 发表于 2022-12-29 22:16:08

Python打包报错,方法都试完了,有没有大佬教教我

#这个是源码,实现的功能是,输入Excel地址,自动把Excel中的数据,粘贴指定的坐标上。



import xlrd
import pyautogui as pg
import pyperclip as pc
import time
import sys
import pyautogui
import tkinter as tk
import xlrd

root = tk.Tk()    #创建窗口
root.title('数据复制程序') #设置窗口标题
root.geometry("400x300")   #设置窗口大小
canvas = tk.Canvas(root,height=200,width=500) #生成画布大小
image_file = tk.PhotoImage(file='welcome.gif') #调用图片名称
image = canvas.create_image(35,0,anchor='nw',image=image_file)#nw以图片的左上角为基准
canvas.pack(side='top') #设置画布位置
tk.Label(root,text='文件地址:',font=('宋体',14)).place(x=45,y=160)#在root窗口创建文字
var_user_name = tk.StringVar()
var_user_name.set('G:\python学习\测试.xls') #默认登录名

entry_user_name = tk.Entry(root,textvariable=var_user_name)#创造一个输入框
entry_user_name.place(x=160,y=160)#输入框位置


def fuzhi():
    inpath = var_user_name.get()#excel文件所在路径
    data = xlrd.open_workbook(inpath, encoding_override='utf-8')
    table = data.sheets()#选定第一张表
    nrows = table.nrows#获取行号
    ncols = table.ncols#获取列号

    for i in range(2, nrows):#第0行为表头
      alldata = table.row_values(i)#循环输出excel表中每一行,即所有数据
      xuhao = alldata#取出表中第一列数据
      mingchen = alldata#取出表中第二列数据
      zhusuju = alldata#取出表中第三列数据
      jianchen = alldata
      tuhao = alldata
      print(xuhao,mingchen,zhusuju,jianchen,tuhao)
   

      class SendMsg(object):      # 自动发送程序
                           
            def __init__(self):                                    
                self.xuhao = xuhao
                self.mingchen =mingchen
                self.zhusuju =zhusuju
                self.jianchen =jianchen
                self.tuhao =tuhao
            def send_msg(self):
                  # 操作间隔为1秒
                pg.PAUSE = 0.5
                  #zhaotupian1 = pyautogui.locateOnScreen('dian1.png') # 寻找到和an8.png一样的图片
                  #tupianxy1 = pyautogui.center(zhaotupian1) # 把寻找到的图片的中心点坐标赋值给 tupianxy
                  #pyautogui.click(tupianxy1)
                pyautogui.click(828,249)

                pyautogui.click(727,285)
             #开始粘贴
                pc.copy(self.xuhao)
                pg.hotkey('ctrl', 'v')

                pyautogui.click(971,280)
         
                pc.copy(self.mingchen)
                pg.hotkey('ctrl', 'v')

            
         
                pyautogui.click(1221,309)
         
                pc.copy(self.zhusuju)
                pg.hotkey('ctrl', 'v')

                pyautogui.click(725,365)
         
                pc.copy(self.jianchen)
                pg.hotkey('ctrl', 'v')

                pyautogui.click(984,462)
         
                pc.copy(self.tuhao)
                pg.hotkey('ctrl', 'v')

                pyautogui.click(737,252)
                  
   
         
      if __name__ == '__main__':
            s = SendMsg()
            # while True:
            for i in range(1):      
                s.send_msg()

    sys.exit(0) # ,退出         
login = tk.Button(root, text='复制开始', command=fuzhi).place(x=170, y=210)            
                  








build的报错日志如下


This file lists modules PyInstaller was not able to find. This does not
necessarily mean this module is required for running your program. Python and
Python 3rd-party packages include a lot of conditional or optional modules. For
example the module 'ntpath' only exists on Windows, whereas the module
'posixpath' only exists on Posix systems.

Types if import:
* top-level: imported at the top-level - look at these first
* conditional: imported within an if-statement
* delayed: imported within a function
* optional: imported within a try-except-statement

IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for
            tracking down the missing module yourself. Thanks!

missing module named _posixshmem - imported by multiprocessing.resource_tracker (conditional), multiprocessing.shared_memory (conditional)
missing module named 'org.python' - imported by copy (optional), xml.sax (delayed, conditional)
missing module named 'java.lang' - imported by platform (delayed, optional), xml.sax._exceptions (conditional)
missing module named multiprocessing.BufferTooShort - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
missing module named multiprocessing.AuthenticationError - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
missing module named _posixsubprocess - imported by subprocess (conditional), multiprocessing.util (delayed)
missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), zipimport (top-level)
excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional), zipimport (top-level)
missing module named pwd - imported by posixpath (delayed, conditional, optional), shutil (delayed, optional), tarfile (optional), pathlib (delayed, optional), subprocess (delayed, conditional, optional), netrc (delayed, conditional), getpass (delayed), http.server (delayed, optional), webbrowser (delayed)
missing module named grp - imported by shutil (delayed, optional), tarfile (optional), pathlib (delayed, optional), subprocess (delayed, conditional, optional)
missing module named posix - imported by os (conditional, optional), posixpath (optional), shutil (conditional), importlib._bootstrap_external (conditional)
missing module named resource - imported by posix (top-level)
missing module named org - imported by pickle (optional)
missing module named multiprocessing.get_context - imported by multiprocessing (top-level), multiprocessing.pool (top-level), multiprocessing.managers (top-level), multiprocessing.sharedctypes (top-level)
missing module named multiprocessing.TimeoutError - imported by multiprocessing (top-level), multiprocessing.pool (top-level)
missing module named fcntl - imported by subprocess (optional)
missing module named multiprocessing.set_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level)
missing module named multiprocessing.get_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level)
missing module named pyimod02_importers - imported by D:\VirtualEnvs\testvenv\Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgutil.py (top-level)
missing module named _scproxy - imported by urllib.request (conditional)
missing module named termios - imported by getpass (optional), tty (top-level)
missing module named AppKit - imported by pyperclip (delayed, conditional, optional), pyautogui._pyautogui_osx (top-level)
missing module named Foundation - imported by pyperclip (delayed, conditional, optional)
missing module named PyQt4 - imported by pyperclip (delayed, conditional, optional)
missing module named PyQt5 - imported by pyperclip (delayed, conditional, optional)
missing module named qtpy - imported by pyperclip (delayed, conditional, optional)
missing module named gtk - imported by pyperclip (delayed, conditional, optional)
missing module named vms_lib - imported by platform (delayed, optional)
missing module named java - imported by platform (delayed)
missing module named _winreg - imported by platform (delayed, optional)
missing module named 'Xlib.XK' - imported by pyautogui._pyautogui_x11 (top-level)
missing module named 'Xlib.ext' - imported by pyautogui._pyautogui_x11 (top-level)
missing module named Xlib - imported by mouseinfo (conditional), pyautogui._pyautogui_x11 (top-level)
missing module named 'Xlib.display' - imported by pyautogui._pyautogui_x11 (top-level)
missing module named Quartz - imported by pygetwindow._pygetwindow_macos (top-level), pyautogui._pyautogui_osx (optional)
missing module named asyncio.DefaultEventLoopPolicy - imported by asyncio (delayed, conditional), asyncio.events (delayed, conditional)
missing module named readline - imported by cmd (delayed, conditional, optional), code (delayed, conditional, optional), pdb (delayed, optional)
missing module named Tkinter - imported by pymsgbox (conditional, optional), mouseinfo (conditional, optional)
missing module named 'rubicon.objc' - imported by mouseinfo (conditional)
missing module named rubicon - imported by mouseinfo (conditional)
missing module named PIL - imported by pyscreeze (conditional, optional), mouseinfo (conditional, optional)
missing module named numpy - imported by pyscreeze (optional)
missing module named cv2 - imported by pyscreeze (optional)
missing module named cStringIO - imported by xlrd.timemachine (conditional)
missing module named copy_reg - imported by cStringIO (top-level)

   

zly1533535226 发表于 2022-12-30 17:52:23

我找到问题原因了,是漏写了一句root.mainloop(),加上之后再打包,运行程序就有我需要的窗口弹出来 。好像和打包没有关系。后面程序运行正常,打包报错日志里面也是这样的。

isdkz 发表于 2022-12-30 09:15:53

看看这个:https://blog.csdn.net/dugushangliang/article/details/100761976/

wp231957 发表于 2022-12-30 09:18:25

百度翻译:此文件列出了PyInstaller找不到的模块
页: [1]
查看完整版本: Python打包报错,方法都试完了,有没有大佬教教我