{"title":"Troubleshooting","version":"2.1","locale":"en","docname":"faq/troubleshooting","url":"/en/2.1/faq/troubleshooting/","canonical":"https://djangodocs.dev/en/2.1/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>Troubleshooting<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 <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code><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>“command not found: django-admin”<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=\"/en/2.1/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=\"/en/2.1/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=\"macos-permissions\">\n<h3>macOS permissions<a class=\"heading-anchor\" href=\"#macos-permissions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>If you’re using macOS, you may see the message “permission denied” 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\nmacOS, a file must be marked as “executable” 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=\"/en/2.1/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 class=\"simple\">\n<li><p>Your system locale may be a default ASCII locale, like the “C” 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</ul>\n<p>Related resources:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/en/2.1/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":"macOS permissions","anchor":"macos-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":"/en/2.1/faq/"}],"prev":{"docname":"faq/contributing","title":"FAQ: Contributing code","url":"/en/2.1/faq/contributing/"},"next":{"docname":"ref/index","title":"API Reference","url":"/en/2.1/ref/"},"formats":{"html":"/en/2.1/faq/troubleshooting/","markdown":"/en/2.1/faq/troubleshooting.md","json":"/en/2.1/faq/troubleshooting.json"},"source":"https://github.com/django/django/blob/stable/2.1.x/docs/faq/troubleshooting.txt","official":"https://docs.djangoproject.com/en/2.1/faq/troubleshooting/","inVersions":["dev","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","1.8"],"inLocales":["en","zh-hans","fr","ja","id","pt-br","ko","es","el","pl"]}