django 项目 相关问题

1、跨越设置

项目跨域访问:参考 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 = ['*']

2、 项目启动

python manage.py runserver 0.0.0.0:8081

3、 项目打包

主要包括django项目框架+vue打包后的静态文件等

参考:Python pyinsatller打包Django项目为exe文件 - loren880898 - 博客园 (cnblogs.com)https://www.cnblogs.com/loren880898/p/14681933.html

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.

参考文章:

完美解决 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 documentationicon-default.png?t=M4ADhttps://pyinstaller.org/en/stable/installation.html#installed-commands

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值