如何让uwsgi在Ubuntu 16.04中使用python2.7而不是python3.5?

时间:2017-09-10 08:04:41

标签: python ubuntu uwsgi

我需要在我的脚本中使用python2.7。我使用uwsgi + nginx进行部署 由于系统是Ubuntu 16.04,因此有两个版本的python 2.7和3.5。

我尝试了什么: 以下一种方式创建了virtuenv:

 virtualenv --python=/usr/bin/python2.7 venv

但它给了我结果:

New python executable in /home/user/venv/bin/python2.7
Also creating executable in /home/user/venv/bin/python

你可以在/ home / user / venv / bin / python中猜到python3.5

我也试过在我的site.ini中放了一个版本的python,我的site.ini文件:

[uwsgi]
project = myproject
uid = user
base = /home/%(uid)/websites
home = %(base)/%(project)/venv
pythonpath = /home/%(uid)/websites/%(project)/venv/bin/python2.7

chdir = %(base)/%(project)
home = %(base)/%(project)/venv
module = %(project).wsgi:application

master = true
processes = 5

socket = /run/uwsgi/%(project).sock
chown-socket = %(uid):www-data

chmod-socket = 660

完成所有操作后,我仍然收到错误:

Sep 10 07:59:49 ubuntu-512mb-fra1-01-sep17 uwsgi[14174]: thunder lock: disabled (you can enable it with --thunder-lock)
Sep 10 07:59:49 ubuntu-512mb-fra1-01-sep17 uwsgi[14174]: uwsgi socket 0 bound to UNIX address /run/uwsgi/myproject.sock fd 3
Sep 10 07:59:49 ubuntu-512mb-fra1-01-sep17 uwsgi[14174]: setuid() to 1000
Sep 10 07:59:49 ubuntu-512mb-fra1-01-sep17 uwsgi[14174]: Python version: 3.5.2 (default, Nov 17 2016, 17:05:23)  [GCC 5.4.0 20160609
Sep 10 07:59:49 ubuntu-512mb-fra1-01-sep17 uwsgi[14174]: Set PythonHome to /home/user/websites/myproject/venv
Sep 10 07:59:49 ubuntu-512mb-fra1-01-sep17 uwsgi[14174]: Fatal Python error: Py_Initialize: Unable to get the locale encoding
Sep 10 07:59:49 ubuntu-512mb-fra1-01-sep17 uwsgi[14174]: ImportError: No module named 'encodings'
Sep 10 07:59:49 ubuntu-512mb-fra1-01-sep17 uwsgi[14174]: Current thread 0x00007fb0561d2700 (most recent call first):
Sep 10 07:59:49 ubuntu-512mb-fra1-01-sep17 uwsgi[14174]: Sun Sep 10 07:59:49 2017 - [emperor] curse the uwsgi instance myproject.ini (
Sep 10 07:59:52 ubuntu-512mb-fra1-01-sep17 uwsgi[14174]: Sun Sep 10 07:59:52 2017 - [emperor] removed uwsgi instance myproject.ini

如您所见,它不使用python2.7

0 个答案:

没有答案