为什么我在尝试调用Django Python shell时遇到错误?

时间:2016-01-23 17:28:55

标签: django python-2.7 windows-7

我当前的python版本是2.7.10,Django的版本是1.9.1,path.py是8.1.2,但每当我尝试通过命令调用python shell时: $ python manage.py shell我遇到了很多错误,结尾看起来像是:

Error in sys.excepthook:
Traceback (most recent call last):
  File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\CrashHandler.py", line 157, in __call__
    report.write(self.make_report(traceback))
  File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\CrashHandler.py", line 215, in make_report
    rpt_add('BZR revision   : %s \n\n' % Release.revision)
AttributeError: 'module' object has no attribute 'revision'

Original exception was:
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\commands\shell.py", line 69, in handle
    self.run_shell(shell=options['interface'])
  File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\commands\shell.py", line 58, in run_shell
    return getattr(self, shell)()
  File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\commands\shell.py", line 41, in ipython
    ip()
  File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\commands\shell.py", line 22, in _ipython_pre_011
    shell = IPShell(argv=[])
  File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\Shell.py", line 73, in __init__
    debug=debug,shell_class=shell_class)
  File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\ipmaker.py", line 521, in make_IPython
    IP.pre_config_initialization()
  File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\iplib.py", line 835, in pre_config_initialization
    self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
  File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\Extensions\pickleshare.py", line 53, in __init__
    if not self.root.isdir():
TypeError: _isdir() takes exactly 1 argument (0 given)

我该如何克服这个问题?

1 个答案:

答案 0 :(得分:0)

通过快速搜索,看起来安装Django和IPython时会发生此错误,因为显然Django会尝试使用IPython shell。

与第一个有类似问题的人的资源:

  

run python manage.py shell occurs errors

在上面的链接中,关于OP问题的评论之一建议查看这个单独的主题以获得答案:

  

https://superuser.com/questions/318655/error-running-ipython3-on-xp-typeerror-isdir-takes-exactly-1-argument-0-gi



获胜的答案如下:

  

最后决定再给这个刺,并设法得到它   工作。解决方案是两线改变   ipython-0.11-py3.2.egg \ IPython \ utils \ pickleshare.py文件,第52行:

     

在:

if not self.root.isdir():
    self.root.makedirs()
     

后:

if not os.path.isdir(self.root):
        os.makedirs(self.root)