centos上環境問題事宜彙總

2021-10-07 22:53:59 字數 854 閱讀 3506

在 linux伺服器上執行**報錯: 

python3中遇到unicodeencodeerror: 『ascii』 codec can』t encode characters in ordinal not in range(128) 

但是在windows上面執行**正常。 

原因是因為:linux系統語言導致的。 

檢視了一下系統環境編碼

>>> import sys

>>> sys.stdout.encoding

'us-ascii'12

3而另一台能正常列印的機器是 en_us.utf-8

export lang="en_us.utf-8"

1儲存退出後重新開啟命令列控制台

(2)使用pythonioencoding

在執行python命令前新增引數 pythonioencoding=utf-8 python test.py

該引數的解釋可檢視官方文件: 

(3)重新定義標準輸出

在**中新增 sys.stdout = codecs.getwriter(「utf-8」)(sys.stdout.detach()) ,使**變為:

import sys

import codecs

sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())

print('中文')

————————————————

如果發現有資訊說,需要安裝tk的開發類庫,直接進行安裝:

sudo apt install tk-dev (ubuntu/debian)

yum install tk-devel (centos)

lnmp環境搭建問題彙總

今天使用lnmp工具搭建了測試環境.遇到了如下幾個問題 這裡通常會想到資料夾許可權,實際是缺少 vhost中缺少 index 配置.2.crit 13488 0 11173 connect to unix tmp php cgi.sock failed 2 no such file or direc...

Docker環境部署問題彙總

具體docker相關使用指導參考 cannot connect to the docker daemon.is the docker daemon running on this host?sudo service docker startfailed to start docker.service...

Flutter MacOS開發環境問題彙總

mac10.15.5環境變數,修改.zshrc檔案 export flutter users develop flutter bin export path path flutter export pub hosted url export flutter storage base url home...