简体   繁体   English

django 和 python manage.py runserver 执行错误

[英]django and python manage.py runserver execution error

When I execute python manage.py runserver command for my django_test projects I get following error:当我为 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

I have never had this problem before and my code always worked fine until I moved the project from one laptop to the other and can not execute it here.我以前从未遇到过这个问题,我的代码一直运行良好,直到我将项目从一台笔记本电脑移到另一台笔记本电脑并且无法在此处执行。

Originaly, it worked fine but the system crashed and it is first time when I am trying to run the code on the new machine.原来,它运行良好,但系统崩溃了,这是我第一次尝试在新机器上运行代码。 I use virtualenv so I would expect everything to work smoothly but it does not ...我使用 virtualenv 所以我希望一切顺利,但它并没有......

Is it a problem with python itself ?是python本身的问题吗?

It looks like you're running against the system version of python on the new laptop, rather than the virtualenv, so it is probably a different version.看起来您在新笔记本电脑上运行的是 python 的系统版本,而不是 virtualenv,所以它可能是一个不同的版本。 You can check this by looking at the version of Python on the virtualenv in the old laptop and the new laptop with python --version - I've seen this error happen in this case to people before.您可以通过查看旧笔记本电脑中的 virtualenv 上的 Python 版本和使用python --version的新笔记本电脑来检查这一点 - 我以前见过这种错误发生在这种情况下。

Your best bet is to create a new virtualenv on the new laptop, and reinstall your packages (hopefully, you have a requirements.txt handy).最好的办法是在新的笔记本电脑上创建一个新的 virtualenv,然后重新安装你的包(希望你有一个 requirements.txt 方便)。 If you need the same version of Python on the new laptop, you'll have to explore getting that version installed on your new laptop (do not overwrite the system version!), and pointing your virtualenv to the install.如果您需要在新笔记本电脑上安装相同版本的 Python,您必须探索在新笔记本电脑上安装该版本(不要覆盖系统版本!),并将您的 virtualenv 指向安装。 Good luck.祝你好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM