項目跨域訪問:參考 Django跨域訪問has been blocked by CORS policy: No ‘Access-Control-Allow-Origin‘ header解決方法_ChangYan.的博客-CSDN博客
0、跨越設置插件安裝
pip install django-cors-header -i http://pypi.doubanio.com/simple --trusted-host pypi.doubanio.com
1、配置修改:
Settings.py
INSTALLED_APPS=[
'corsheaders',
]
MIDDLEWARE=[
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
]
CORS_ORIGIN_ALLOW_ALL=True
CORS_ALLOW_CREDENTIALS=True
2、允許遠程訪問
ALLOWED_HOSTS = ['*']
python manage.py runserver 0.0.0.0:8081
主要包括django項目框架+vue打包後的靜態文件等
參考:Python pyinsatller打包Django項目為exe文件 - loren880898 - 博客園 (cnblogs.com)https://www.cnblogs.com/loren880898/p/14681933.html
0、打包時的異常信息:
TypeError: _get_sysconfigdata_name() missing 1 required positional argument: 'check_exists'
修改
D:\ProgramData\Anaconda3\Lib\site-packages\PyInstaller\hooks\hook-distutils.py
D:\ProgramData\Anaconda3\Lib\site-packages\PyInstaller\hooks\hook-sysconfig.py
的內容:
添加:
import sysconfig
print(sysconfig.__file__)修改:
_get_sysconfigdata_name(check_exists=True)
保存後重新打包
===================================================
1、pyinstaller -D .\manage.py 打包時打印的
異常信息:【主要與pyinstaller依賴有關】
PyInstaller.exceptions.ImportErrorWhenRunningHook: Failed to import module __PyInstaller_hooks_0_IPython required by hook for module d:\programdata\anaconda3\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-IPython.py. Please check whether module __PyInstaller_hooks_0_IPython actually exists and whether the hook is compatible with your version of d:\programdata\anaconda3\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-IPython.py: You might want to read more about hooks in the manual and provide a pull-request to improve PyInstaller.
參考文章:
完美解決 pyinstaller程序打包問題 之 Hooks報錯_小明的女朋友的博客-CSDN博客_pyinstaller 打包失敗https://blog.csdn.net/weixin_42430971/article/details/121726334
解決過程:
嘗試第5種方式更新,然後刪除項目目錄下上次打包生成的文件
卸載環境中的pyinstaller,使用conda重新安裝
參考:
附鏈接:
1、pyInstaller
How to Install PyInstaller — PyInstaller 5.1 documentationhttps://pyinstaller.org/en/stable/installation.html#installed-commands