【问题标题】:Django shell doesn't work?Django外壳不起作用?
【发布时间】:2014-06-04 21:22:01
【问题描述】:

当我启动 django shell 时,我得到了这个内存错误! 我在没有root权限的共享主机上。我无法安装 Ipython,但我需要 shell。

$ python manage.py shell
Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_manager(settings)
  File "/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/django/core/management/base.py", line 218, in execute
    output = self.handle(*args, **options)
  File "/django/core/management/base.py", line 347, in handle
    return self.handle_noargs(**options)
  File "/django/core/management/commands/shell.py", line 26, in handle_noargs
    import IPython
  File "/usr/lib64/python2.7/site-packages/IPython/__init__.py", line 58, in <module>
    __import__(name,glob,loc,[])
  File "/usr/lib64/python2.7/site-packages/IPython/Shell.py", line 30, in <module>
    import ctypes
  File "/usr/lib64/python2.7/ctypes/__init__.py", line 555, in <module>
    _reset_cache()
  File "/usr/lib64/python2.7/ctypes/__init__.py", line 279, in _reset_cache
    CFUNCTYPE(c_int)(lambda: None)
MemoryError

【问题讨论】:

  • 安装 Python 包不需要 root 权限。设置一个venv并将其全部安装在本地。

标签: python django


【解决方案1】:

您可以使用 --plain 选项。

也许这个答案可以帮助你:Python/Django shell won't start

【讨论】:

    【解决方案2】:

    请检查 /tmp 目录中的设置。是否也设置了粘性位?如果你执行 ls -ltrd /tmp,它应该类似于以下内容

    # ls -ltrd /tmp drwxrwxrwt 6 root root 4096 Feb 5 16:43 /tmp

    如果 /tmp 是专门挂载的,你也可以尝试重新挂载(你需要 root 才能这样做)。我的 /tmp 目录有问题,所以我卸载它并重新创建了 /tmp 的新版本。然后上面的错误对我的应用程序来说就消失了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-20
      • 2020-12-31
      相关资源
      最近更新 更多