首页 > 解决方案 > 如何使用 camelot 模块创建可执行文件?

问题描述

我正在尝试使用 auto-py-to-exe 从我的脚本创建可执行文件。一旦我运行这个 exe 文件,就会出现以下错误:

Traceback(最近一次调用最后一次):ModuleNotFoundError 中的文件“GUI_PDF_scraper.py”,第 5 行:没有名为“camelot”的模块

下面的代码:

from tkinter import *
from tkinter import filedialog
import os
import camelot
import shutil
import pandas as pd

# ========================   functions    ==============================================================================

file_name = []


def search_for_file_path():
    global file_name
    
    current_dir = os.getcwd()
    file = filedialog.askopenfile(parent=window, initialdir=current_dir, title='Please select a directory')
    file_name = file.name
    file_entry.insert(0, file_name)


def scrapping():
    global file_name

    dfs = []

    # camelot reader / this two lines reads and export pdf pages to separate CSV files
    tables = camelot.read_pdf(str(file_name), pages="1-end")
    tables.export('data.csv', f='csv', compress=False)


    for root, dirs, files in os.walk("./"):
        # select file name
        for file in files:
            # check the extension of files
            if file.endswith('.csv'):
                # append dataframes to the list of dataframes
                dfs.append(pd.read_csv(file))

    # creation of concatenated dataframes(panda) / if df is just one concatenation is not needed
    if len(dfs) < 2:
        dfs[0].to_csv("result_/final_file.csv", index=False)
    else:
        merged = pd.concat(dfs)
        merged.to_csv("result_/final_file.csv", index=False)

    # working files move to trash and removal from trash directory
    source = os.listdir("./")
    destination = "./trash_"
    for files in source:
        if files.endswith(".csv"):
            shutil.move(files, destination)
            os.remove(f"trash_/{files}")

标签: pythonexeexecutablepython-camelot

解决方案


推荐阅读