tom635 发表于 2023-8-15 09:34

pyinstaller打包Sanic应用

代码很简单,什么都没做就返回一个json,就是打包失败

涛之雨 发表于 2023-8-15 12:32

没有相关代码,看图写作吗?

看图上是css文件没有打包进去。。。

TWYX 发表于 2023-8-15 14:21

看图是路径错误,未找到你的style.css文件

一只大菜猫 发表于 2023-8-15 14:34

源码补给,最少給个打包语句啊,看图写作还容易点

tom635 发表于 2023-8-15 18:12

一只大菜猫 发表于 2023-8-15 14:34
源码补给,最少給个打包语句啊,看图写作还容易点

源码就这些,没有css相关的文件

tom635 发表于 2023-8-15 18:14

一只大菜猫 发表于 2023-8-15 14:34
源码补给,最少給个打包语句啊,看图写作还容易点

源码就这些,打包参数就一个F,那个css文件应该是sanic源码中的,不知道怎么弄

tom635 发表于 2023-8-15 18:15

TWYX 发表于 2023-8-15 14:21
看图是路径错误,未找到你的style.css文件

css文件应该是sanic源码中的,该怎么打包呢

tom635 发表于 2023-8-15 18:18

涛之雨 发表于 2023-8-15 12:32
没有相关代码,看图写作吗?

看图上是css文件没有打包进去。。。

应该是sanic中的css文件,该怎么引入呢

TWYX 发表于 2023-8-16 09:06

tom635 发表于 2023-8-15 18:15
css文件应该是sanic源码中的,该怎么打包呢

from sanic import Sanic
from sanic.response import json
app = Sanic('test')

@app.route('/url2image')
async def InsertImage2ExcelFomUrl(request):
    return json({'name':'tom'})

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8989, debug=False)


打包

Microsoft Windows [版本 10.0.19045.3324]
(c) Microsoft Corporation。保留所有权利。

G:\项目文件\测试一下>pyinstaller -F test.py
1224 INFO: PyInstaller: 5.13.0
1224 INFO: Python: 3.11.2
1233 INFO: Platform: Windows-10-10.0.19045-SP0
1255 INFO: wrote G:\项目文件\测试一下\test.spec
1305 INFO: Extending PYTHONPATH with paths
['G:\\项目文件\\测试一下']
2038 INFO: checking Analysis
2038 INFO: Building Analysis because Analysis-00.toc is non existent
2038 INFO: Initializing module dependency graph...
2040 INFO: Caching module graph hooks...
2058 INFO: Analyzing base_library.zip ...
4257 INFO: Loading module hook 'hook-heapq.py' from 'D:\\Program Files\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
4412 INFO: Loading module hook 'hook-encodings.py' from 'D:\\Program Files\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
6476 INFO: Loading module hook 'hook-pickle.py' from 'D:\\Program Files\\Python311\\Lib\\site-packages\\PyInstaller\\hooks'...
8560 INFO: Caching module dependency graph...
8676 INFO: running Analysis Analysis-00.toc
8706 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by D:\Program Files\Python311\python.exe
8945 INFO: Analyzing G:\项目文件\测试一下\test.py
8947 INFO: Processing module hooks...
8956 INFO: Looking for ctypes DLLs
8966 INFO: Analyzing run-time hooks ...
8968 INFO: Including run-time hook 'D:\\Program Files\\Python311\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
8991 INFO: Looking for dynamic libraries
438 INFO: Extra DLL search directories (AddDllDirectory): []
438 INFO: Extra DLL search directories (PATH): ['D:\\Program Files\\Python311\\Scripts\\', 'D:\\Program Files\\Python311\\', 'D:\\zt\\bin\\git\\cmd', 'D:\\zt\\bin\\sliksvn', 'D:\\zt\\zbox\\nssm\\win32', 'C:\\Users\\tongy\\AppData\\Local\\Programs\\Python\\Python37-32\\Scripts\\', 'C:\\Users\\tongy\\AppData\\Local\\Programs\\Python\\Python37-32\\', 'C:\\Windows\\system32', 'C:\\Windows', 'C:\\Windows\\System32\\Wbem', 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\', 'C:\\Windows\\System32\\OpenSSH\\', 'C:\\Program Files\\Intel\\WiFi\\bin\\', 'C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\', 'C:\\ProgramData\\chocolatey\\bin', 'C:\\Users\\tongy\\AppData\\Local\\Microsoft\\WindowsApps', 'D:\\Program Files\\JetBrains\\PyCharm Community Edition 2022.3\\bin', 'D:\\Program Files\\Microsoft VS Code\\bin', 'C:\\Users\\tongy\\AppData\\Roaming\\npm', 'C:\\Program Files (x86)\\Tencent\\微信web开发者工具\\dll', 'D:\\Program Files\\platform-tools', 'D:\\gccc\\bin', 'D:\\gccc\\bin', 'D:\\Program Files\\nodejs\\', 'C:\\Program Files\\dotnet\\', 'C:\\Users\\tongy\\AppData\\Local\\Programs\\Python\\Python37-32\\Scripts\\', 'C:\\Users\\tongy\\AppData\\Local\\Programs\\Python\\Python37-32\\', 'C:\\Users\\tongy\\AppData\\Local\\Microsoft\\WindowsApps', 'D:\\Program Files\\JetBrains\\PyCharm Community Edition 2022.3\\bin', 'D:\\Program Files\\Microsoft VS Code\\bin', 'C:\\Program Files\\JetBrains\\WebStorm\\bin', 'C:\\Users\\tongy\\AppData\\Roaming\\npm']
9789 INFO: Looking for eggs
9790 INFO: Using Python library D:\Program Files\Python311\python311.dll
9790 INFO: Found binding redirects:
[]
9792 INFO: Warnings written to G:\项目文件\测试一下\build\test\warn-test.txt
9810 INFO: Graph cross-reference written to G:\项目文件\测试一下\build\test\xref-test.html
9861 INFO: checking PYZ
9861 INFO: Building PYZ because PYZ-00.toc is non existent
9862 INFO: Building PYZ (ZlibArchive) G:\项目文件\测试一下\build\test\PYZ-00.pyz
10151 INFO: Building PYZ (ZlibArchive) G:\项目文件\测试一下\build\test\PYZ-00.pyz completed successfully.
10156 INFO: checking PKG
10156 INFO: Building PKG because PKG-00.toc is non existent
10158 INFO: Building PKG (CArchive) test.pkg
12054 INFO: Building PKG (CArchive) test.pkg completed successfully.
12055 INFO: Bootloader D:\Program Files\Python311\Lib\site-packages\PyInstaller\bootloader\Windows-64bit-intel\run.exe
12055 INFO: checking EXE
12058 INFO: Building EXE because EXE-00.toc is non existent
12058 INFO: Building EXE from EXE-00.toc
12060 INFO: Copying bootloader EXE to G:\项目文件\测试一下\dist\test.exe.notanexecutable
12090 INFO: Copying icon to EXE
12100 INFO: Copying icons from ['D:\\Program Files\\Python311\\Lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
12102 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
12102 INFO: Writing RT_ICON 1 resource with 3752 bytes
12103 INFO: Writing RT_ICON 2 resource with 2216 bytes
12104 INFO: Writing RT_ICON 3 resource with 1384 bytes
12105 INFO: Writing RT_ICON 4 resource with 37019 bytes
12106 INFO: Writing RT_ICON 5 resource with 9640 bytes
12107 INFO: Writing RT_ICON 6 resource with 4264 bytes
12109 INFO: Writing RT_ICON 7 resource with 1128 bytes
12114 INFO: Copying 0 resources to EXE
12114 INFO: Embedding manifest in EXE
12116 INFO: Updating manifest in G:\项目文件\测试一下\dist\test.exe.notanexecutable
12117 INFO: Updating resource type 24 name 1 language 0
12121 INFO: Appending PKG archive to EXE
12129 INFO: Fixing EXE headers
12205 INFO: Building EXE from EXE-00.toc completed successfully.



打包成功了

tom635 发表于 2023-8-16 09:40

TWYX 发表于 2023-8-16 09:06
from sanic import Sanic
from sanic.response import json
app = Sanic('te ...

打包是能成功,但是一运行就报那个缺失css的错误:'(weeqw
页: [1]
查看完整版本: pyinstaller打包Sanic应用