- 使用pip安装相关moudle
pyi-makespec -D manage.py
- urls.py中添加
from django.conf.urls import static
from django.conf import settings
urlpatterns += static.static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
- manage.spec中添加
datas=[(r'C:\Users\harry\Desktop\youtubeSearch\static',r'.\static'), (r'C:\Users\harry\Desktop\youtubeSearch\templates', r'.\templates')],
pyinstaller manage.spec
- 拷贝config.txt和key到./dist/manage/
- 创建 YoutubeSearch.py
import os
os.system('manage.exe runserver 127.0.0.1:12345 --noreload')
- 打包
pyinstaller -F -i youtube_search.ico .\YoutubeSearch.py
- 将YoutubeSearch.exe拷贝到manage文件夹
- 双击YoutubeSearch.exe运行