程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Problems related to Django project

編輯:Python

1、 Span settings

Project cross domain access : Reference resources  Django Cross domain access has been blocked by CORS policy: No ‘Access-Control-Allow-Origin‘ header resolvent _ChangYan. The blog of -CSDN Blog

0、 Install plug-ins across settings
pip install django-cors-header -i http://pypi.doubanio.com/simple --trusted-host pypi.doubanio.com
1、 Configuration modification :
Settings.py
INSTALLED_APPS=[
'corsheaders',
]
MIDDLEWARE=[
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
]
CORS_ORIGIN_ALLOW_ALL=True
CORS_ALLOW_CREDENTIALS=True
2、 Allow remote access
ALLOWED_HOSTS = ['*']

2、 Project start

python manage.py runserver 0.0.0.0:8081

3、 Project package

It mainly includes django The project framework +vue Packed static files, etc

Reference resources :Python pyinsatller pack Django The project is exe file - loren880898 - Blog Garden (cnblogs.com)https://www.cnblogs.com/loren880898/p/14681933.html

3.1 Problems and solutions during packaging

0、 Exception information during packaging :

TypeError: _get_sysconfigdata_name() missing 1 required positional argument: 'check_exists'

modify

D:\ProgramData\Anaconda3\Lib\site-packages\PyInstaller\hooks\hook-distutils.py

D:\ProgramData\Anaconda3\Lib\site-packages\PyInstaller\hooks\hook-sysconfig.py

The content of :

add to :

import sysconfig
print(sysconfig.__file__)

modify :

_get_sysconfigdata_name(check_exists=True)

Save and repack

===================================================

1、pyinstaller -D .\manage.py Printed when packaging

Abnormal information :【 Mainly with pyinstaller Dependency related 】

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.

Reference article :

Perfect solution pyinstaller Program packaging problem And Hooks Report errors _ Xiaoming's girlfriend's blog -CSDN Blog _pyinstaller Packaging failed https://blog.csdn.net/weixin_42430971/article/details/121726334

To solve the process :

Try No 5 Two ways to update , Then delete the last package generated file in the project directory

  

Uninstall... In the environment pyinstaller, Use conda reinstall

Reference resources :

Link attached :

1、pyInstaller

How to Install PyInstaller — PyInstaller 5.1 documentationhttps://pyinstaller.org/en/stable/installation.html#installed-commands


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved