-1

After creating a new project and trying to run it, I get something like this:

 * Environment: development
 * Debug mode: off
Traceback (most recent call last):
  File "C:\Users\Sebastian\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Sebastian\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Sebastian\PycharmProjects\informatyka\venv\lib\site-packages\flask\__main__.py", line 3, in <module>
    main()
  File "C:\Users\Sebastian\PycharmProjects\informatyka\venv\lib\site-packages\flask\cli.py", line 994, in main
    cli.main(args=sys.argv[1:])
  File "C:\Users\Sebastian\PycharmProjects\informatyka\venv\lib\site-packages\flask\cli.py", line 600, in main
    return super().main(*args, **kwargs)
  File "C:\Users\Sebastian\PycharmProjects\informatyka\venv\lib\site-packages\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "C:\Users\Sebastian\PycharmProjects\informatyka\venv\lib\site-packages\click\core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\Sebastian\PycharmProjects\informatyka\venv\lib\site-packages\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\Sebastian\PycharmProjects\informatyka\venv\lib\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\Sebastian\PycharmProjects\informatyka\venv\lib\site-packages\click\decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\Users\Sebastian\PycharmProjects\informatyka\venv\lib\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\Sebastian\PycharmProjects\informatyka\venv\lib\site-packages\flask\cli.py", line 853, in run_command
    run_simple(
  File "C:\Users\Sebastian\PycharmProjects\informatyka\venv\lib\site-packages\werkzeug\serving.py", line 1010, in run_simple
    inner()
  File "C:\Users\Sebastian\PycharmProjects\informatyka\venv\lib\site-packages\werkzeug\serving.py", line 950, in inner
    srv = make_server(
  File "C:\Users\Sebastian\PycharmProjects\informatyka\venv\lib\site-packages\werkzeug\serving.py", line 782, in make_server
    return ThreadedWSGIServer(
  File "C:\Users\Sebastian\PycharmProjects\informatyka\venv\lib\site-packages\werkzeug\serving.py", line 688, in __init__
    super().__init__(server_address, handler)  # type: ignore
  File "C:\Users\Sebastian\AppData\Local\Programs\Python\Python38-32\lib\socketserver.py", line 452, in __init__
    self.server_bind()
  File "C:\Users\Sebastian\AppData\Local\Programs\Python\Python38-32\lib\http\server.py", line 139, in server_bind
    self.server_name = socket.getfqdn(host)
  File "C:\Users\Sebastian\AppData\Local\Programs\Python\Python38-32\lib\socket.py", line 756, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe6 in position 4: invalid continuation byte

I've already tried reinstalling python, changing python version, updating PIP but none of these helped. The same problem is with creating a Diango project.

davidism
  • 121,510
  • 29
  • 395
  • 339
Hasanoes
  • 3
  • 1
  • 3

1 Answers1

-1

Just asking, have you tried using a 64-bit version of Python? I'm not really sure about how Django behaves on 32-bit environments.

Anyway, the main issue seems to be related to your WSGI server, not to Django itself. You seem to be trying to be using threading inside your WSGI server, which being contained on your python process it will be tied to a single thread, as all Python processes.

My recommendation: make your wsgi.py as simple as possible and let a WSGI external server like gunicorn handle parallelism. An example of your wsgi.py could be something like:

import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hellodjango.settings")

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

# Apply WSGI middleware here.
from helloworld.wsgi import HelloWorldApplication  # Change the defaults for your app paths
application = HelloWorldApplication(application)

And to run your app as a server, just run the following command: gunicorn helloworld.wsgi, again changing helloworld for your application name. Check gunicorn docs for more info about running instances in parallel, it's just the --workers configuration parameter you must set with the number of workers your computer can handle (normally your number of CPUs - 1).

Cheers!

Matías Zanolli
  • 468
  • 3
  • 8