| 1 |
=============== |
| 2 |
Troubleshooting |
| 3 |
=============== |
| 4 |
|
| 5 |
This page contains some advice about errors and problems commonly encountered |
| 6 |
during the development of Django applications. |
| 7 |
|
| 8 |
.. _troubleshooting-django-admin: |
| 9 |
|
| 10 |
Problems running ``django-admin`` |
| 11 |
================================= |
| 12 |
|
| 13 |
``command not found: django-admin`` |
| 14 |
----------------------------------- |
| 15 |
|
| 16 |
:doc:`django-admin </ref/django-admin>` should be on your system path if you |
| 17 |
installed Django via ``pip``. If it's not in your path, ensure you have your |
| 18 |
virtual environment activated and you can try running the equivalent command |
| 19 |
``python -m django``. |
| 20 |
|
| 21 |
macOS permissions |
| 22 |
----------------- |
| 23 |
|
| 24 |
If you're using macOS, you may see the message "permission denied" when |
| 25 |
you try to run ``django-admin``. This is because, on Unix-based systems like |
| 26 |
macOS, a file must be marked as "executable" before it can be run as a program. |
| 27 |
To do this, open Terminal.app and navigate (using the ``cd`` command) to the |
| 28 |
directory where :doc:`django-admin </ref/django-admin>` is installed, then |
| 29 |
run the command ``sudo chmod +x django-admin``. |
| 30 |
|
| 31 |
Miscellaneous |
| 32 |
============= |
| 33 |
|
| 34 |
I'm getting a ``UnicodeDecodeError``. What am I doing wrong? |
| 35 |
------------------------------------------------------------ |
| 36 |
|
| 37 |
This class of errors happen when a bytestring containing non-ASCII sequences is |
| 38 |
transformed into a Unicode string and the specified encoding is incorrect. The |
| 39 |
output generally looks like this: |
| 40 |
|
| 41 |
.. code-block:: pytb |
| 42 |
|
| 43 |
UnicodeDecodeError: 'ascii' codec can't decode byte 0x?? in position ?: |
| 44 |
ordinal not in range(128) |
| 45 |
|
| 46 |
The resolution mostly depends on the context, however here are two common |
| 47 |
pitfalls producing this error: |
| 48 |
|
| 49 |
* Your system locale may be a default ASCII locale, like the "C" locale on |
| 50 |
UNIX-like systems (can be checked by the ``locale`` command). If it's the |
| 51 |
case, please refer to your system documentation to learn how you can change |
| 52 |
this to a UTF-8 locale. |
| 53 |
|
| 54 |
Related resources: |
| 55 |
|
| 56 |
* :doc:`Unicode in Django </ref/unicode>` |
| 57 |
* https://wiki.python.org/moin/UnicodeDecodeError |