【问题标题】:create a pdf from a pyinstaller python frozen code从 pyinstaller python 冻结代码创建一个 pdf
【发布时间】:2019-11-20 14:06:55
【问题描述】:

我想从 Python 创建一个 pdf 文件,其中包含 seaborn 绘图、图像和文本。 在 jupyter notebook 中:fig1.savefig("export-sns-plot.png")pdf.output("add_image.pdf") 确实会导出图像和包含图像的 pdf 文件。

但是当我使用 Pyinstaller 冻结代码并启动 exe 时没有任何反应,求助..

谢谢

# librairies import
import pandas as pd
from fpdf import FPDF
import seaborn as sns
sns.set()

#dataset import
outils1 = pd.read_csv("projet.csv")
#colums rename
df1 = outils1.rename(columns = {"Unnamed: 0": "Axes","Unnamed: 1":"Reponse"})

#plot generation
x1= df1.Axes
y1= df1.Reponse
sns_plot1 = sns.barplot(x1,y1,data=df1)

#save the plot
fig1 = sns_plot1.get_figure()
fig1.savefig("export-sns-plot.png")

pdf = FPDF(orientation = "L")

# Page 1
pdf.add_page()
pdf.image("export-sns-plot.png", x=10, y=20, w=100) # plot insert as a png file

# pdf generation     
pdf.output("add_image.pdf")

【问题讨论】:

    标签: python pdf fpdf


    【解决方案1】:

    查看 Pweave 库(此处的文档:http://mpastell.com/pweave/)。我不确定这就是你要找的东西,但是使用 pweave,你可以从 python 脚本或 ipython notebook 中创建一个带有绘图、文本和代码的 pdf。

    【讨论】:

      猜你喜欢
      • 2018-10-26
      • 2021-02-25
      • 1970-01-01
      • 2014-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-16
      • 1970-01-01
      相关资源
      最近更新 更多