使用老师给的源码运行 python manage.py runserver 时报错

来源:3-2 配置表单页面

田丰丰丰丰丰丰丰

2019-03-08

我是直接下载课程提供的完整源码想运行下看看效果,前面这几步都做了

  1. 先安装mysql
    安装的时候需要密码设置为root
  2. 通过navicat 新建数据库 库名为mxonline
  3. navicat 导入sql文件
  4. pip install -r requirements.txt 安装依赖包
  5. http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python
    下载 MySQL_python-1.2.5-cp27-none-win_amd64.whl
    然后pip install MySQL_python-1.2.5-cp27-none-win_amd64.whl 安装mysqldb驱动

然后在虚拟环境下运行 python manage.py runserver 时出错
报错信息如下

(testvir) C:\Users\hello\Desktop\code\MxOnlie>python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\hello\Envs\testvir\lib\site-packages\django\core\management\__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "C:\Users\hello\Envs\testvir\lib\site-packages\django\core\management\__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\hello\Envs\testvir\lib\site-packages\django\core\management\__init__.py", line 176, in fetch_command
    commands = get_commands()
  File "C:\Users\hello\Envs\testvir\lib\site-packages\django\utils\lru_cache.py", line 100, in wrapper
    result = user_function(*args, **kwds)
  File "C:\Users\hello\Envs\testvir\lib\site-packages\django\core\management\__init__.py", line 71, in get_commands
    for app_config in reversed(list(apps.get_app_configs())):
  File "C:\Users\hello\Envs\testvir\lib\site-packages\django\apps\registry.py", line 137, in get_app_configs
    self.check_apps_ready()
  File "C:\Users\hello\Envs\testvir\lib\site-packages\django\apps\registry.py", line 124, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

安装的包如下

(testvir) C:\Users\hello\Desktop\code\MxOnlie>pip list
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Package                Version
---------------------- ----------
certifi                2018.11.29
chardet                3.0.4
Django                 1.9
django-crispy-forms    1.6.1
django-formtools       1.0
django-pure-pagination 0.3.0
django-simple-captcha  0.4.6
DjangoUeditor          1.8.143
httplib2               0.9.2
idna                   2.8
MySQL-python           1.2.5
Pillow                 3.4.2
pip                    19.0.3
requests               2.21.0
setuptools             40.8.0
six                    1.12.0
urllib3                1.24.1
wheel                  0.33.1

在非虚拟环境下也出错,但报错信息有区别:

C:\Users\hello\Desktop\code\MxOnlie>python manage.py runserver
Unhandled exception in thread started by <function wrapper at 0x000000000472D4A8>
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 249, in raise_last_exception
    six.reraise(*_exception)
  File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "C:\Python27\lib\site-packages\django\__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Python27\lib\site-packages\django\apps\registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "C:\Python27\lib\site-packages\django\apps\config.py", line 90, in create
    module = import_module(entry)
  File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "C:\Users\hello\Desktop\code\MxOnlie\extra_apps\xadmin\__init__.py", line 4, in <module>
    from xadmin.sites import AdminSite, site
  File "C:\Users\hello\Desktop\code\MxOnlie\extra_apps\xadmin\sites.py", line 3, in <module>
    from future.utils import iteritems
ImportError: No module named future.utils

就像把代码跑起来,要怎么解决呀。

写回答

2回答

Ethreal

2019-03-08

而且//img.mukewang.com/szimg/5c81f1890001c8a805600572.jpg  讲师里面的源码你下载的哪一个? 我看你运行显示的2.7和1.9  你是不是拷错版本了,这个url的错误只是集中在django版本和xadmin的版本不对应的情况下出现

0
2
Ethreal
回复
田丰丰丰丰丰丰丰
现在是什么报错了?
2019-03-10
共2条回复

Ethreal

2019-03-08

首先这个 django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.  错误是需要 pip install future 和 pip install six  另外安装这两个包 ,其次 在哪个环境装包就要在哪个环境中用 除非你几个环境都是一样的

0
7
bobby
回复
Ethreal
正解!
2019-03-10
共7条回复

Python3.6+django+xadmin,打造在线教育平台

【毕设】Python 2.7到3.6 完美适配,Django升级2.0

3677 学习 · 4038 问题

查看课程