1、跨越设置
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 = ['*']
2、 项目启动
python manage.py runserver 0.0.0.0:8081
3、 项目打包
主要包括django项目框架+vue打包后的静态文件等
3.1 打包时出现的问题与解决办法
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.
参考文章:
解决过程:
尝试第5种方式更新,然后删除项目目录下上次打包生成的文件
卸载环境中的pyinstaller,使用conda重新安装
参考:
附链接:
1、pyInstaller