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'

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章