Python Django manage.py shell属性错误模块'ast'没有属性'AnnAssign'

时间:2018-04-02 19:18:53

标签: django python-3.x

所以我正在使用Django中的这个测试应用程序,我想通过python shell向我的sql表添加一些数据。我从CMD运行以下命令

λ python manage.py shell

这给了我以下输出:

Traceback (most recent call last):   File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)   File "C:\Python\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
    utility.execute()   File "C:\Python\lib\site-packages\django\core\management\__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)   File "C:\Python\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
    self.execute(*args, **cmd_options)   File "C:\Python\lib\site-packages\django\core\management\base.py", line 335, in execute
    output = self.handle(*args, **options)   File "C:\Python\lib\site-packages\django\core\management\commands\shell.py", line 99, in handle
    return getattr(self, shell)(options)   File "C:\Python\lib\site-packages\django\core\management\commands\shell.py", line 35, in ipython
    from IPython import start_ipython   File "C:\Python\lib\site-packages\IPython\__init__.py", line 55, in <module>
    from .terminal.embed import embed   File "C:\Python\lib\site-packages\IPython\terminal\embed.py", line 15, in <module>
    from IPython.core.interactiveshell import DummyMod, InteractiveShell   File "C:\Python\lib\site-packages\IPython\core\interactiveshell.py", line 109, in <module>
    _assign_nodes         = (ast.AugAssign, ast.AnnAssign, ast.Assign) AttributeError: module 'ast' has no attribute 'AnnAssign'

我正在使用Python 3和Django 2.0.3。

我自己尝试的一些事情:

我检查了ipython是使用pip的最新版本,我的数据库在SQL社区服务器运行上运行并且工作正常,Django服务器本身也运行没有问题。

编辑:我做了一些挖掘AST是标准python库的一部分。但是,我没有发现我的python安装有任何问题,任何想法?

EDIT2:尝试重新安装Ipython,同样的回溯错误。

1 个答案:

答案 0 :(得分:0)

好吧,所以我通过PIP完全重新安装了Django和Mysqlclient,解决了这个问题。我现在已经接受了django shell。