Hello!

There is a server with debian 8.5, nginx, django 1.10, uwsgi, python (2.7, 3.4) all this is used without vitrual env (venv). There is a site on django which pours errors

'ascii' codec can't encode character u'\u0419' in position 2: ordinal not in range(128) Request Method: GET Django Version: 1.10.4 Exception Type: UnicodeEncodeError Exception Value: 'ascii' codec can't encode character u'\u0419' in position 2: ordinal not in range(128) Exception Location: /usr/local/lib/python2.7/dist-packages/django/utils/encoding.py in force_text, line 80 Python Executable: /usr/bin/uwsgi-core Python Version: 2.7.9 

Errors due to the fact that python uses Cyrillic there, and python2 does not know how to do it without specifying codepages.

Question: How to make it all run under python3.4 without using virtualenv? Add. infa:

 [uwsgi] PROJECT_NAME=%n PROJECT_ROOT=/var/www/%(PROJECT_NAME) chdir=%(PROJECT_ROOT)/src/ touch-reload=%(PROJECT_ROOT)/reload module=core.wsgi plugins=python3,http master=true workers=2 uid=www-data gid=www-data disable-logging=true 

-

 # update-alternatives --config python Есть 2 варианта для альтернативы python (предоставляет /usr/bin/python). Выбор Путь Приор Состояние ------------------------------------------------------------ 0 /usr/bin/python2.7 1 автоматический режим 1 /usr/bin/python2.7 1 ручной режим * 2 /usr/bin/python3.4 0 ручной режим 

-

 Fri Dec 30 14:31:39 2016 - *** Starting uWSGI 2.0.7-debian (64bit) on [Fri Dec 30 14:31:38 2016] *** Fri Dec 30 14:31:39 2016 - compiled with version: 4.9.1 on 25 October 2014 19:17:54 Fri Dec 30 14:31:39 2016 - os: Linux-3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2+deb8u3 (2016-07-02) Fri Dec 30 14:31:39 2016 - machine: x86_64 Fri Dec 30 14:31:39 2016 - clock source: unix Fri Dec 30 14:31:39 2016 - pcre jit disabled Fri Dec 30 14:31:39 2016 - detected number of CPU cores: 2 Fri Dec 30 14:31:39 2016 - current working directory: / Fri Dec 30 14:31:39 2016 - setgid() to 33 Fri Dec 30 14:31:39 2016 - setuid() to 33 Fri Dec 30 14:31:39 2016 - your processes number limit is 1912 Fri Dec 30 14:31:39 2016 - your memory page size is 4096 bytes Fri Dec 30 14:31:39 2016 - detected max file descriptor number: 1024 Fri Dec 30 14:31:39 2016 - lock engine: pthread robust mutexes Fri Dec 30 14:31:39 2016 - thunder lock: disabled (you can enable it with --thunder-lock) Fri Dec 30 14:31:39 2016 - uwsgi socket 0 bound to UNIX address /run/uwsgi/app/pjreo.is74/socket fd 3 Fri Dec 30 14:31:39 2016 - Python version: 2.7.9 (default, Mar 1 2015, 13:01:26) [GCC 4.9.2] Fri Dec 30 14:31:40 2016 - *** Python threads support is disabled. You can enable it with --enable-threads *** Fri Dec 30 14:31:40 2016 - Python main interpreter initialized at 0x257a410 Fri Dec 30 14:31:40 2016 - your server socket listen backlog is limited to 100 connections Fri Dec 30 14:31:40 2016 - your mercy for graceful operations on workers is 60 seconds Fri Dec 30 14:31:40 2016 - mapped 218304 bytes (213 KB) for 2 cores Fri Dec 30 14:31:40 2016 - *** Operational MODE: preforking *** Fri Dec 30 09:31:42 2016 - WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x257a410 pid: 1095 (default app) Fri Dec 30 09:31:42 2016 - *** uWSGI is running in multiple interpreter mode *** Fri Dec 30 09:31:42 2016 - spawned uWSGI master process (pid: 1095) Fri Dec 30 09:31:42 2016 - spawned uWSGI worker 1 (pid: 1507, cores: 1) Fri Dec 30 09:31:42 2016 - spawned uWSGI worker 2 (pid: 1508, cores: 1) 
  • and how django gets started? - Mikhail Vaysman
  • How the module is installed via pip3: Django == 1.10.4 Django-Select2 == 5.8.10 django-appconf == 1.0.2 - user232578
  • Global python should not be changed (you just break the system). If you can not run Django in your environment, then ask about it. Now, in general, the description contradicts itself (you say that you have installed Django for Python 3, but at the same time show errors for Python 2). It is not clear what caused UnicodeEncodeError for you (both Python 2 and 3 can get such an error). Run Django on exactly the Python where you put this library. Isolate UnicodeEncodeError and show a minimal but complete example of the code that leads to it. Show full traceback. - jfs
  • @jfs what's the contradiction? Nose poke please. What I need to start is written in python3, why my environment is started using python2 - I have no idea and try to find out - in fact you can see it from the question. No contradictions - this is the first. Secondly, nothing terrible will happen from the global change of the interpreter version, you just need to take this into account when installing new packages and updating old ones, you are driving at a completely different topic, this does not apply to the question, please do not offtopic. - user232578
  • If anyone is interested, besides the global version change of python (Hi @jfs), it was also necessary to change the version of uwsgi about what I had no idea (Sorry, dear, I didn’t answer my question myself) and resolve the dependencies of the modules between python 2/3 (uwsgi-plugin-python3 as an example) and everything worked fine. Popularly: python, jango and others like them are not at all in business , the problem was that, as seen in the first post from the logs, uwsgi used python2, but needed python3. If you want, you can write it to the child. - user232578

0