Bootstrap

uwsgi错误记录(一)

使用uwsgi启动报如下错误:

Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'

环境现状是有系统自带的python2.7和自己安装的3.6.

刚开始以为是linux主机编码集的问题,查了相关资料是python之间调用包导致的,那么就好解决了,通过设置PYTHONPATH把引用到python3的所有路径:

export PYTHONPATH=/usr/local/lib/python3.6/lib-dynload:/usr/local/lib/python3.6/site-packages:/usr/local/lib/python3.6

OK,完美解决。

 

如何查看这个包的路径是什么:

Python 3.6.0a1 (default, Feb 15 2019, 14:32:46)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> dir(math)
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']
>>> math.__file__
'/usr/local/lib/python3.6/lib-dynload/math.cpython-36m-x86_64-linux-gnu.so'

 

;