Benature / WordReview

📚 背单词网页 Django + MySQL + Pug + JS
https://benature.github.io/WordReview/
GNU Lesser General Public License v3.0
576 stars 72 forks source link

执行python manage.py时,出现configparser.NoSectionError: No section: 'custom'报错 #20

Closed karumo10 closed 3 years ago

karumo10 commented 3 years ago

描述问题 我在按照详细安装指引进行安装时,进行到第四步(前戏),在执行

python manage.py makemigrations
python manage.py migrate

时,遇到报错configparser.NoSectionError: No section: 'custom'.同时,执行

python manage.py runserver

时,也发生类似报错,且并没有弹出localhost的网页。详细报错信息、配置环境等附后。 复现问题 复现问题的步骤:

  1. conda create -n wordsReviewEnv
    conda install -n wordsReviewEnv python
  2. 
    pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
    pip install D:\ChromeDownload\mysqlclient-1.4.6-cp39-cp39-win_amd64.whl
(此时发现`mysqlclient`不能自动build,使用网上的.whl文件install,此时环境中的package如下:

packages in environment at C:\Users\uzmak.conda\envs\wordsReviewEnv:

#

Name Version Build Channel

asgiref 3.3.4 pypi_0 pypi beautifulsoup4 4.9.3 pypi_0 pypi bs4 0.0.1 pypi_0 pypi ca-certificates 2021.4.13 haa95532_1 certifi 2020.12.5 py39haa95532_0 chardet 4.0.0 pypi_0 pypi django 3.0.7 pypi_0 pypi django-appconf 1.0.4 pypi_0 pypi django-compressor 2.4.1 pypi_0 pypi django-mysql 3.3.0 pypi_0 pypi django-sass-processor 0.8 pypi_0 pypi idna 2.10 pypi_0 pypi libsass 0.19.4 pypi_0 pypi lxml 4.6.3 pypi_0 pypi mysqlclient 1.4.6 pypi_0 pypi numpy 1.20.2 pypi_0 pypi openssl 1.1.1k h2bbff1b_0 pandas 1.2.4 pypi_0 pypi pip 21.0.1 py39haa95532_0 pymysql 0.9.3 pypi_0 pypi pypugjs 5.8.1 pypi_0 pypi python 3.9.4 h6244533_0 python-dateutil 2.8.1 pypi_0 pypi pytz 2021.1 pypi_0 pypi rcssmin 1.0.6 pypi_0 pypi requests 2.25.1 pypi_0 pypi rjsmin 1.1.0 pypi_0 pypi setuptools 52.0.0 py39haa95532_0 soupsieve 2.2.1 pypi_0 pypi sqlite 3.35.4 h2bbff1b_0 sqlparse 0.4.1 pypi_0 pypi tzdata 2020f h52ac0ba_0 urllib3 1.26.4 pypi_0 pypi vc 14.2 h21ff451_1 vs2015_runtime 14.27.29016 h5e58377_2 wheel 0.36.2 pyhd3eb1b0_0 wincertstore 0.2 py39h2bbff1b_0 xlrd 2.0.1 pypi_0 pypi

3. 执行

python manage.py makemigrations python manage.py migrate

出现如下报错:

Traceback (most recent call last): File "C:\Users\uzmak\Documents\WordReview\WordReview\manage.py", line 88, in main() File "C:\Users\uzmak\Documents\WordReview\WordReview\manage.py", line 84, in main execute_from_command_line(sys.argv) File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\site-packages\django\core\management__init.py", line 401, in execute_from_command_line utility.execute() File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\site-packages\django\core\management__init.py", line 345, in execute settings.INSTALLED_APPS File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\site-packages\django\conf__init.py", line 76, in getattr self._setup(name) File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\site-packages\django\conf__init.py", line 63, in _setup self._wrapped = Settings(settings_module) File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\site-packages\django\conf__init.py", line 142, in init mod = importlib.import_module(self.SETTINGS_MODULE) File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\importlib\init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 972, in _find_and_load_unlocked File "", line 228, in _call_with_frames_removed File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 790, in exec_module File "", line 228, in _call_with_frames_removed File "C:\Users\uzmak\Documents\WordReview\WordReview\WordReview\init.py", line 2, in if config.get('custom', 'db_type') == 'mysql': File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\configparser.py", line 781, in get d = self._unify_values(section, vars) File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\configparser.py", line 1149, in _unify_values raise NoSectionError(section) from None configparser.NoSectionError: No section: 'custom' Traceback (most recent call last): File "C:\Users\uzmak\Documents\WordReview\WordReview\manage.py", line 88, in main() File "C:\Users\uzmak\Documents\WordReview\WordReview\manage.py", line 84, in main execute_from_command_line(sys.argv) File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\site-packages\django\core\management\init__.py", line 401, in execute_from_command_line utility.execute() File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\site-packages\django\core\management\init__.py", line 345, in execute settings.INSTALLED_APPS File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\site-packages\django\conf\init.py", line 76, in getattr__ self._setup(name) File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\site-packages\django\conf\init__.py", line 63, in _setup self._wrapped = Settings(settings_module) File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\site-packages\django\conf\init.py", line 142, in init mod = importlib.import_module(self.SETTINGS_MODULE) File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\importlib\init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 972, in _find_and_load_unlocked File "", line 228, in _call_with_frames_removed File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 790, in exec_module File "", line 228, in _call_with_frames_removed File "C:\Users\uzmak\Documents\WordReview\WordReview\WordReview\init__.py", line 2, in if config.get('custom', 'db_type') == 'mysql': File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\configparser.py", line 781, in get d = self._unify_values(section, vars) File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\configparser.py", line 1149, in _unify_values raise NoSectionError(section) from None configparser.NoSectionError: No section: 'custom'


如果直接执行

python manage.py runserver

则出现以下报错:

Traceback (most recent call last): File "C:\Users\uzmak\Documents\WordReview\WordReview\manage.py", line 88, in main() File "C:\Users\uzmak\Documents\WordReview\WordReview\manage.py", line 84, in main execute_from_command_line(sys.argv) File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\site-packages\django\core\management__init.py", line 401, in execute_from_command_line utility.execute() File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\site-packages\django\core\management__init.py", line 345, in execute settings.INSTALLED_APPS File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\site-packages\django\conf__init.py", line 76, in getattr__ self._setup(name) File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\site-packages\django\conf\init__.py", line 63, in _setup self._wrapped = Settings(settings_module) File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\site-packages\django\conf\init.py", line 142, in init mod = importlib.import_module(self.SETTINGS_MODULE) File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\importlib\init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 972, in _find_and_load_unlocked File "", line 228, in _call_with_frames_removed File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 790, in exec_module File "", line 228, in _call_with_frames_removed File "C:\Users\uzmak\Documents\WordReview\WordReview\WordReview\init__.py", line 2, in if config.get('custom', 'db_type') == 'mysql': File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\configparser.py", line 781, in get d = self._unify_values(section, vars) File "C:\Users\uzmak.conda\envs\wordsReviewEnv\lib\configparser.py", line 1149, in _unify_values raise NoSectionError(section) from None configparser.NoSectionError: No section: 'custom'



**操作环境(请提供以下完整数据):**

- 操作系统:Windows 10 19042.928
- 配置环境:conda 4.9.2,虚拟环境。环境内python版本:Python 3.9.4。环境内package:上文列出
- 使用方式:源码
- 数据库类型:sqlite(实际上还没到这一步)
- 浏览器:(还没到这一步)

<!-- 最后 -->
<!-- 请点下右上角的 Preview 确认预览显示是否理想🙂 谢谢配合 -->
Benature commented 3 years ago

看报错的话,能不能展示下config.conf文件的内容?看一下有没有custom部分

karumo10 commented 3 years ago

好像没有config.conf文件诶...

Benature commented 3 years ago

安装步骤写了👇🏻

进入项目文件夹内,复制一份config_sample.conf文件,改名为config.conf。