请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

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

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

  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

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

正在回答 回答被采纳积分+3

2回答

Ethreal 2019-03-08 12:38:46

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

0 回复 有任何疑惑可以回复我~
Ethreal 2019-03-08 10:10:00

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

0 回复 有任何疑惑可以回复我~
  • 安装了你说的两个包以后报错信息变成了这样:
    ImportError: No module named urls.base
    回复 有任何疑惑可以回复我~ 2019-03-08 10:46:38
  • Ethreal 回复 提问者 田丰丰丰丰丰丰丰 #2
    xadmin报的这个错把,拉下github的xadmin 覆盖下在试试
    回复 有任何疑惑可以回复我~ 2019-03-08 11:01:25
  • 提问者 田丰丰丰丰丰丰丰 回复 Ethreal #3
    使用github上的源码重新安装了xadmin和依赖的包,报错变成了这样 ImportError: cannot import name getfullargspec
    顺便说一下,源码中附带的运行说明也没有要求安装xadmin呀。
    回复 有任何疑惑可以回复我~ 2019-03-08 12:19:14
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信