{"title":"Troubleshooting","version":"1.8","locale":"en","docname":"faq/troubleshooting","url":"/en/1.8/faq/troubleshooting/","canonical":"https://djangodocs.dev/en/1.8/faq/troubleshooting/","summary":"This page contains some advice about errors and problems commonly encountered during the development of Django applications.","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 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>“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/1.8/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\">python setup.py</code>. If it’s not on your path, you can\nfind it in <code class=\"docutils literal notranslate\">site-packages/django/bin</code>, where <code class=\"docutils literal notranslate\">site-packages</code> is a directory\nwithin your Python installation. Consider symlinking to <a class=\"reference internal\" href=\"/en/1.8/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\">/usr/local/bin</code>.</p>\n<p>If <code class=\"docutils literal notranslate\">django-admin</code> doesn’t work but <code class=\"docutils literal notranslate\">django-admin.py</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\">django-admin</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 “permission denied” when\nyou try to run <code class=\"docutils literal notranslate\">django-admin</code>. This is because, on Unix-based systems like\nOS X, 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\">cd</code> command) to the\ndirectory where <a class=\"reference internal\" href=\"/en/1.8/ref/django-admin/\"><span class=\"doc\">django-admin</span></a> is installed, then\nrun the command <code class=\"docutils literal notranslate\">sudo chmod +x django-admin</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\">UnicodeDecodeError</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> codec can<span class=\"s1\">&#39;t decode byte 0x?? in position ?:</span>\nordinal <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 “C” locale on\nUNIX-like systems (can be checked by the <code class=\"docutils literal notranslate\">locale</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>my_string <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\">u''</code> prefix or even better, add the\n<code class=\"docutils literal notranslate\">from __future__ import unicode_literals</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\">u''</code> prefix.</p>\n</li>\n</ul>\n<p>Related resources:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/en/1.8/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":"/en/1.8/faq/"}],"prev":{"docname":"faq/contributing","title":"FAQ: Contributing code","url":"/en/1.8/faq/contributing/"},"next":{"docname":"ref/index","title":"API Reference","url":"/en/1.8/ref/"},"formats":{"html":"/en/1.8/faq/troubleshooting/","markdown":"/en/1.8/faq/troubleshooting.md","json":"/en/1.8/faq/troubleshooting.json"},"source":"https://github.com/django/django/blob/stable/1.8.x/docs/faq/troubleshooting.txt","official":"https://docs.djangoproject.com/en/1.8/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"]}