django和python manage.py runserver执行错误

时间:2015-06-14 20:50:14

标签: python django manage.py

当我为我的django_test项目执行python manage.py runserver命令时,我收到以下错误:

System check identified no issues (0 silenced).
June 14, 2015 - 20:43:03
Django version 1.8.2, using settings 'django_test.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 49, in execute
    super(Command, self).execute(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 88, in handle
    self.run(**options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 97, in run
    autoreload.main(self.inner_run, None, options)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 323, in main
    reloader(wrapped_main_func, args, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 289, in python_reloader
    reloader_thread()
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 265, in reloader_thread
    change = fn()
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 190, in inotify_code_changed
    update_watch()
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 184, in update_watch
    wm.add_watch(path, mask)
  File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 1903, in add_watch
    exclude_filter)
  File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 1822, in __add_watch
    wd = self._inotify_wrapper.inotify_add_watch(self._fd, path, mask)
  File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 150, in inotify_add_watch
    return self._inotify_add_watch(fd, pathname, mask)
  File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 245, in _inotify_add_watch
    return self._libc.inotify_add_watch(fd, pathname, mask)
ctypes.ArgumentError: argument 2: <type 'exceptions.TypeError'>: expected CString instance instead of c_char_Array_64

我之前从未遇到过这个问题,我的代码总是正常工作,直到我将项目从一台笔记本电脑移到另一台笔记本电脑并且无法在此处执行。

原来,它工作正常,但系统崩溃,这是我第一次尝试在新机器上运行代码。我使用virtualenv所以我希望一切顺利,但它不会......

python本身有问题吗?

1 个答案:

答案 0 :(得分:1)

看起来你在新的笔记本电脑上运行python的系统版本,而不是virtualenv,所以它可能是一个不同的版本。您可以通过查看旧笔记本电脑中的virtualenv上的Python版本和python --version的新笔记本电脑来查看 - 我已经看到此错误发生在以前的人身上。

您最好的选择是在新笔记本电脑上创建一个新的virtualenv,并重新安装您的软件包(希望您有一个requirements.txt方便)。如果您需要在新笔记本电脑上使用相同版本的Python,您必须探索在新笔记本电脑上安装该版本(不要覆盖系统版本!),并将您的virtualenv指向安装。祝你好运。