python - 从 pyinstaller python 冻结代码创建一个 pdf
问题描述
我想从 Python 创建一个 pdf 文件,其中包含 seaborn 绘图、图像和文本。在 jupyter notebook 中,行 :确实会导出图像和包含图像的 pdf 文件fig1.savefig("export-sns-plot.png")
。pdf.output("add_image.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")
解决方案
查看 Pweave 库(此处的文档:http://mpastell.com/pweave/ )。我不确定这是你要找的东西,但是使用 pweave,你可以从 python 脚本或 ipython notebook 中创建一个带有绘图、文本和代码的 pdf。
推荐阅读
- python-3.x - 使用pytoexeconverter将python脚本转换为exe后进程仍在后台运行
- node.js - 无法捕获错误?:NodeJS/Hyperledger
- javascript - 实习生黄瓜插件错误:尚未注册名为“黄瓜”的插件
- symfony - 在服务中注入 EventDispatcher 在生产环境中不起作用 - symfony 3.4
- r - 将因子转换为R中的多列
- dom - 无法使用 testcafe 在反应应用程序中获取 DOM
- python-3.x - 日志模块中的文件名与模块
- postgresql - 如何在 Redis 中存储提要数据?
- azure - 以 Forbidden Errors 开头的 Kubernetes 仪表板
- javascript - 单击时遍历数组并通过另一次单击更改专辑