Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/356.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Uwsgi?我的python主路径在哪里?_Python_Linux_Ubuntu - Fatal编程技术网

如何使用Uwsgi?我的python主路径在哪里?

如何使用Uwsgi?我的python主路径在哪里?,python,linux,ubuntu,Python,Linux,Ubuntu,我正在尝试使用ec2部署我的django应用程序。我遵循一些指示 但当我尝试连接Uwsgi和我的django应用程序时,出现了一个问题 (unifolio-back) ubuntu@ip-172-31-37-172:~$ which python /home/ubuntu/.local/share/virtualenvs/unifolio-back-_HCbnSkq/bin/python (unifolio-back) ubuntu@ip-172-31-37-172:~$ uwsgi --ht

我正在尝试使用ec2部署我的django应用程序。我遵循一些指示

但当我尝试连接Uwsgi和我的django应用程序时,出现了一个问题

(unifolio-back) ubuntu@ip-172-31-37-172:~$ which python
/home/ubuntu/.local/share/virtualenvs/unifolio-back-_HCbnSkq/bin/python

(unifolio-back) ubuntu@ip-172-31-37-172:~$ uwsgi --http :8080 --home /home/ubuntu/.local/share/virtualenvs/unifolio-back-_HCbnSkq/bin/python --chdir /srv/unifolio-back/ -w mysite.wsgi
*** Starting uWSGI 2.0.19.1 (64bit) on [Sat Dec 19 09:54:26 2020] ***
compiled with version: 7.5.0 on 19 December 2020 01:14:28
os: Linux-5.4.0-1029-aws #30~18.04.1-Ubuntu SMP Tue Oct 20 11:09:25 UTC 2020
nodename: ip-172-31-37-172
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/ubuntu
detected binary path: /home/ubuntu/.local/share/virtualenvs/unifolio-back-_HCbnSkq/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /srv/unifolio-back/
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 3802
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :8080 fd 4
spawned uWSGI http 1 (pid: 2408)
uwsgi socket 0 bound to TCP address 127.0.0.1:40925 (port auto-assigned) fd 3
Python version: 3.6.9 (default, Oct  8 2020, 12:12:24)  [GCC 8.4.0]
!!! Python Home is not a directory: /home/ubuntu/.local/share/virtualenvs/unifolio-back-_HCbnSkq/bin/python !!!
Set PythonHome to /home/ubuntu/.local/share/virtualenvs/unifolio-back-_HCbnSkq/bin/python
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f54d0d2a600 (most recent call first):
Aborted (core dumped)

有什么问题?我猜python路径有问题。。。但是我无法找到解决这个问题的方法。

Ubuntu使用了
uwsgi
的基于插件的架构。为了成功运行Python 3应用程序,您需要
uwsgi-plugin-python3
插件。首先,使用apt安装它:

$ sudo apt install uwsgi-plugin-python3
然后,将
uwsgi
命令更改为以下命令:

uwsgi --http :8080 --virtualenv /home/ubuntu/.local/share/virtualenvs/unifolio-back-_HCbnSkq \
      --chdir /srv/unifolio-back/ -w mysite.wsgi --plugins python3