无法在 PyQt5 中映射 icu 数据文件



我在pyqt5中使用了QWebEngineView。尝试使用HTML文件在QWebEngineView中导出PDF。当我在VS Code中运行该文件时,pdf导出并运行良好,但当我在cmd 中使用此命令将该python文件转换为exe时

pyinstaller --onefile mycode.py

并运行mycode.exe我得到这个错误:无法mmap icu数据文件

以下是我在pyqt5:中的全部代码

import sys
from PyQt5.QtWidgets import (QHBoxLayout, QPushButton, QWidget, 
QApplication, QVBoxLayout, QMessageBox)
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import QWebEngineView

class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
vbox = QVBoxLayout(self)
hbox = QHBoxLayout()
self.webEngineView = QWebEngineView()
self.loadPage()
expBtn = QPushButton('Export', self)
expBtn.clicked.connect(self.onClicked)
hbox.addWidget(expBtn)
vbox.addWidget(self.webEngineView)
vbox.addLayout(hbox)
self.setLayout(vbox)
self.setGeometry(300, 300, 350, 250)
self.setWindowTitle('QWebEngineView')
self.show()
def onClicked(self):
self.webEngineView.page().printToPdf('myfile.pdf')
QMessageBox.information(self, 'info', 'page exported')
def loadPage(self):
with open('html.html', encoding="utf8") as f:
html = f.read()
self.webEngineView.setHtml(html)
def main():
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())

if __name__ == '__main__':
main()

这是我的HTML:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">

<style>
th, td {
border-bottom:1px solid black;
border-right:1px solid black;
text-align : center;
padding : 3px;
}
* {
direction: rtl;
}     

.img{
border-bottom:1px solid black;
border-right:1px solid black;
text-align : center;

}
.center {

margin-left: auto;
margin-right: auto;
width:95%;
border:1px solid black;

}
</style>

</head>
<body style="font-family: Arial">

<div style="border: 4px double black;">
<h3 style="text-align:center; font-size: 30px;">فاکتور خرید</h3>
<h3 style="text-align:center ;font-size: 30px;">شرکت برنا نوآوران پویا</h3>
<img src="icon.jpg" alt="Paris" style="width: 5%;">
</div>
<div style="border-bottom: 1px dashed black; border-left: 4px double black; border-right: 4px double black;border-top: 1px double black;">
<p style="text-align:right; font-size: 20px; padding-right: 30px;"> تاریخ : </p>
<p style="text-align:right; font-size: 20px; padding-right: 30px;">زمان :</p>
</div>
<div style="border-bottom: 4px double black; border-left: 4px double black; border-right: 4px double black;border-top: 1px dashed black;">
<br></br>

<table class = "center">
<tr >
<th>شماره بارنامه</th>
<th>تاریخ ورود محموله</th>
<th>نرخ دلار</th>
<th>نرخ پوند</th>
<th>نرخ یورو</th>
<th>وزن کل</th>
<th>هزینه گمرک</th>
<th>هزینه حمل</th>
<th>هزینه خرید</th>
<th>هزینه کارمزد</th>
<th>مجموع هزینه کل</th>
<th>تعداد کل کالا</th>

</tr>
<tr>
<td>3333</td>
<td>345</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>


</tr>

</table>
<br></br>
<br></br>

<table class = "center">
<tr >
<th>اسم کالا</th>
<th>تعداد تکی</th>
<th>قمیت خرید نهایی</th>
<th>وزن نهایی به گرم</th>
<th>قیمت کل</th>

</tr>
<tr>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td> 
</tr>
<tr>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td> 
</tr>
<tr>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td> 
</tr>
<tr>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td>
<td>30000000</td> 
</tr>

</table>

<br></br>

<p style="border-bottom: 1px solid black;border-right: 1px solid black; border-radius: 2px; text-align:right; font-size: 20px; margin-right:30px; width: 50%; height: 40px;">
<span style="display: inline-block; margin-right: 5px; margin-bottom: 7px; margin-top: 7px;">مجموع قیمت کل :</span>
<span style="display: inline-block; margin-right: 3px; margin-bottom: 7px; margin-top: 7px;">34343</span>
</p>

<p style="border-bottom: 1px dashed"></p>
<br></br>
<table class = "center">
<tr >
<th>فاکتور خرید</th>
<th>بارنامه</th>



</tr>

<td class = "img">
<img src="run.jpg" style="width: 90%;">
</td>
<td class = "img">
<img src="run.jpg" style="width: 90%;">
</td>
</tr>
</table>
<br></br>
<br></br>

<table class = "center">
<tr >
<th>رسید خرید ۱</th>
<th>رسید خرید ۲</th>             

</tr>

<td class = "img">
<img src="run.jpg" style="width: 90%;">
</td>
<td class = "img">
<img src="run.jpg" style="width: 90%;">
</td>
</tr>
</table>
<br></br>
<br></br>
<p style="text-align:right; font-size: 20px; padding-right: 30px;">سرمایه گذاران :</p>
<br></br>
<br></br>
<br></br>
<p style="text-align:right; font-size: 20px; padding-right: 30px;"></p>
<p style="text-align:right; font-size: 20px; padding-right: 30px;">توضیحات تکمیلی :</p>
<br></br>
<br></br>
<br></br>
<p style="text-align:right; font-size: 20px; padding-right: 30px;"></p>
<p style="text-align:right; font-size: 20px; padding-right: 30px;">نام کاربر :</p>
<br></br>
<br></br>
<br></br>
<p style="text-align:right; font-size: 20px; padding-right: 30px;"></p>


</div>
</body>
</html>

有人知道当我将python文件转换为exe时如何修复这个错误吗?

我在一个中文网站上找到了一个解决方案。我不得不在myapp.exe中放入一些文件。以下是链接:参观https://cxyzjd.com/article/meimeieee/115024971