[英]Django Runserver error while executing "Python manage.py runserver"
[英]django and python manage.py runserver execution 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
我以前從未遇到過這個問題,我的代碼一直運行良好,直到我將項目從一台筆記本電腦移到另一台筆記本電腦並且無法在此處執行。
原來,它運行良好,但系統崩潰了,這是我第一次嘗試在新機器上運行代碼。 我使用 virtualenv 所以我希望一切順利,但它並沒有......
是python本身的問題嗎?
看起來您在新筆記本電腦上運行的是 python 的系統版本,而不是 virtualenv,所以它可能是一個不同的版本。 您可以通過查看舊筆記本電腦中的 virtualenv 上的 Python 版本和使用python --version
的新筆記本電腦來檢查這一點 - 我以前見過這種錯誤發生在這種情況下。
最好的辦法是在新的筆記本電腦上創建一個新的 virtualenv,然后重新安裝你的包(希望你有一個 requirements.txt 方便)。 如果您需要在新筆記本電腦上安裝相同版本的 Python,您必須探索在新筆記本電腦上安裝該版本(不要覆蓋系統版本!),並將您的 virtualenv 指向安裝。 祝你好運。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.