I want to use uWSGI in python 3.6

Asked 2 years ago, Updated 2 years ago, 153 views

I decided to use uWSGI to create an application using nginx for the web server and flask for the application part.

I was referring to the following site, but
Milestone#4 starts uWSGI with an error.
https://vladikk.com/2013/09/12/serving-flask-with-nginx-on-ubuntu/

When I checked the uWSGI log, the error content was as follows.
It says python version: 2.7.14, but since python version is 3.6 using pyenv, I think the problem is that the path is wrong, but it doesn't go away very often.
Could you give me some advice?

*** Starting uWSGI 2.0.17.1 (64bit) on [Tue Oct 23 14:06:13 2018] ***
...some omitted...
*** WARNING: you are running uWSGI without its master process manager***
Your processes number limit is 3860
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 socket 0 bound to UNIX address/home/ec2-user/***/***_uwsgi.sock fd3
Python version: 2.7.14 (default, May 21 2018, 18:31:34) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
Set PythonHome to /home/ec2-user/.pyenv/versions/3.6.0/lib/python 3.6/
ImportError: No module named site

References

$ python -- version
Python 3.6.0

~/.bash_profile Contents

# export PATH = $PATH: $HOME/.local/bin: $HOME/bin

exportPYENV_ROOT="$HOME/.pyenv"
PATH="$PYENV_ROOT/bin:$PATH"
event "$(pyenv init-)"
export PYTHONHOME="$PYENV_ROOT/versions/3.6.0/lib/python 3.6"
export PYTHONPATH="$PYENV_ROOT/versions/3.6.0/lib/python 3.6"

~/.bashrc

# User specific aliases and functions
PYTHONPATH=: /home/ec2-user/.pyenv/versions/3.6.0/lib/python 3.6/
#PYTHONPATH=/home/ec2-user/***/***

***_uwsi.ini

·Some omitted...
home=/home/ec2-user/.pyenv/versions/3.6.0/lib/python 3.6/
# pythonpath=~/.pyenv/shims/python 3.6
pythonpath=/home/ec2-user/.pyenv/versions/3.6.0/lib/python 3.6
·Some omitted...

python python3 nginx pyenv uwsgi

2022-09-30 21:35

1 Answers

The referenced site appears to have created a virtualenv environment using Python 2 on the system and installed uwsi and so on using pip in the virtual environment.Kuunosuke wants to install 3.6 on pyenv and use it, so I think it will be a different procedure than following the reference site.

Did the uwsi log show python version:2.7.14 because when you created the virtualenv environment, you created the virtual environment using python2 on the system instead of python3.6 installed in pyenv?

If I were to do the same thing in python 3.6,

virtualenvvenv

where it is said that

virtualenv-p/home/ec2-user/.pyenv/versions/3.6.0/bin/pythonvenv

As an example, it would be good to specify that you create a virtual environment based on 3.6 of the pyenv you created, not the system python 2. (Or you can use it because 3.6 has the equivalent of virtualenv in the standard library./home/ec2-user/.pyenv/versions/3.6.0/bin/python-mvenvenvenvenv>)

Instead of setting the PYTHONPATH by yourself, you can leave it to virtualenv and pip install in the activated virtual environment to do the same as the reference site.
Once activated, it will be displayed at the prompt (venv), so you should check it and install the library correctly.


2022-09-30 21:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.