{"title":"トラブルシューティング","version":"1.9","locale":"ja","docname":"faq/troubleshooting","url":"/ja/1.9/faq/troubleshooting/","canonical":"https://djangodocs.dev/ja/1.9/faq/troubleshooting/","summary":"This page contains some advice about errors and problems commonly encountered during the development of Django applications. Problems running django-admin Link to…","html":"<h1>トラブルシューティング<a class=\"heading-anchor\" href=\"#troubleshooting\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>This page contains some advice about errors and problems commonly encountered\nduring the development of Django applications.</p>\n<section id=\"problems-running-django-admin\">\n<span id=\"troubleshooting-django-admin\"></span><h2>Problems running django-admin<a class=\"heading-anchor\" href=\"#problems-running-django-admin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"command-not-found-django-admin\">\n<h3>&quot;command not found: django-admin&quot;<a class=\"heading-anchor\" href=\"#command-not-found-django-admin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><a class=\"reference internal\" href=\"/ja/1.9/ref/django-admin/\"><span class=\"doc\">django-admin</span></a> should be on your system path if you\ninstalled Django via <code class=\"docutils literal notranslate\"><span class=\"pre\">python</span> <span class=\"pre\">setup.py</span></code>. If it's not on your path, you can\nfind it in <code class=\"docutils literal notranslate\"><span class=\"pre\">site-packages/django/bin</span></code>, where <code class=\"docutils literal notranslate\"><span class=\"pre\">site-packages</span></code> is a directory\nwithin your Python installation. Consider symlinking to <a class=\"reference internal\" href=\"/ja/1.9/ref/django-admin/\"><span class=\"doc\">django-admin</span></a> from some place on your path, such as\n<code class=\"file docutils literal notranslate\"><span class=\"pre\">/usr/local/bin</span></code>.</p>\n<p>If <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> doesn't work but <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin.py</span></code> does, you're probably\nusing a version of Django that doesn't match the version of this documentation.\n<code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> is new in Django 1.7.</p>\n</section>\n<section id=\"mac-os-x-permissions\">\n<h3>Mac OS X permissions<a class=\"heading-anchor\" href=\"#mac-os-x-permissions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>If you're using Mac OS X, you may see the message &quot;permission denied&quot; when\nyou try to run <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code>. This is because, on Unix-based systems like\nOS X, a file must be marked as &quot;executable&quot; before it can be run as a program.\nTo do this, open Terminal.app and navigate (using the <code class=\"docutils literal notranslate\"><span class=\"pre\">cd</span></code> command) to the\ndirectory where <a class=\"reference internal\" href=\"/ja/1.9/ref/django-admin/\"><span class=\"doc\">django-admin</span></a> is installed, then\nrun the command <code class=\"docutils literal notranslate\"><span class=\"pre\">sudo</span> <span class=\"pre\">chmod</span> <span class=\"pre\">+x</span> <span class=\"pre\">django-admin</span></code>.</p>\n</section>\n</section>\n<section id=\"miscellaneous\">\n<h2>Miscellaneous<a class=\"heading-anchor\" href=\"#miscellaneous\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"i-m-getting-a-unicodedecodeerror-what-am-i-doing-wrong\">\n<h3>I'm getting a <code class=\"docutils literal notranslate\"><span class=\"pre\">UnicodeDecodeError</span></code>. What am I doing wrong?<a class=\"heading-anchor\" href=\"#i-m-getting-a-unicodedecodeerror-what-am-i-doing-wrong\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>This class of errors happen when a bytestring containing non-ASCII sequences is\ntransformed into a Unicode string and the specified encoding is incorrect. The\noutput generally looks like this:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"ne\">UnicodeDecodeError</span><span class=\"p\">:</span> <span class=\"s1\">&#39;ascii&#39;</span> <span class=\"n\">codec</span> <span class=\"n\">can</span><span class=\"s1\">&#39;t decode byte 0x?? in position ?:</span>\n<span class=\"n\">ordinal</span> <span class=\"ow\">not</span> <span class=\"ow\">in</span> <span class=\"nb\">range</span><span class=\"p\">(</span><span class=\"mi\">128</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>The resolution mostly depends on the context, however here are two common\npitfalls producing this error:</p>\n<ul>\n<li><p>Your system locale may be a default ASCII locale, like the &quot;C&quot; locale on\nUNIX-like systems (can be checked by the <code class=\"docutils literal notranslate\"><span class=\"pre\">locale</span></code> command). If it's the\ncase, please refer to your system documentation to learn how you can change\nthis to a UTF-8 locale.</p></li>\n<li><p>You created raw bytestrings, which is easy to do on Python 2:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">my_string</span> <span class=\"o\">=</span> <span class=\"s1\">&#39;café&#39;</span>\n</code></pre></div>\n<p>Either use the <code class=\"docutils literal notranslate\"><span class=\"pre\">u''</span></code> prefix or even better, add the\n<code class=\"docutils literal notranslate\"><span class=\"pre\">from</span> <span class=\"pre\">__future__</span> <span class=\"pre\">import</span> <span class=\"pre\">unicode_literals</span></code> line at the top of your file\nso that your code will be compatible with Python 3.2 which doesn't support\nthe <code class=\"docutils literal notranslate\"><span class=\"pre\">u''</span></code> prefix.</p>\n</li>\n</ul>\n<p>Related resources:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/ja/1.9/ref/unicode/\"><span class=\"doc\">Unicode in Django</span></a></p></li>\n<li><p><a class=\"reference external\" href=\"https://wiki.python.org/moin/UnicodeDecodeError\">https://wiki.python.org/moin/UnicodeDecodeError</a></p></li>\n</ul>\n</section>\n</section>","rootId":"troubleshooting","toc":[{"title":"Problems running django-admin","anchor":"problems-running-django-admin","children":[{"title":"\"command not found: django-admin\"","anchor":"command-not-found-django-admin","children":[]},{"title":"Mac OS X permissions","anchor":"mac-os-x-permissions","children":[]}]},{"title":"Miscellaneous","anchor":"miscellaneous","children":[{"title":"I'm getting a UnicodeDecodeError. What am I doing wrong?","anchor":"i-m-getting-a-unicodedecodeerror-what-am-i-doing-wrong","children":[]}]}],"breadcrumbs":[{"docname":"faq/index","title":"Django FAQ よくある質問","url":"/ja/1.9/faq/"}],"prev":{"docname":"faq/contributing","title":"FAQ: コードへの貢献","url":"/ja/1.9/faq/contributing/"},"next":{"docname":"ref/index","title":"API Reference","url":"/ja/1.9/ref/"},"formats":{"html":"/ja/1.9/faq/troubleshooting/","markdown":"/ja/1.9/faq/troubleshooting.md","json":"/ja/1.9/faq/troubleshooting.json"},"source":"https://github.com/django/django/blob/stable/1.9.x/docs/faq/troubleshooting.txt","official":"https://docs.djangoproject.com/ja/1.9/faq/troubleshooting/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9"],"inLocales":["en","fr","ja","id","pt-br","es"]}