jhao104 / proxy_pool

Python ProxyPool for web spider
https://jhao104.github.io/proxy_pool/
MIT License
21.48k stars 5.17k forks source link

windows报错UnicodeDecodeError: 'gbk' codec can't decode byte 0xbf in position 2: illegal mu ltibyte sequence #140

Closed pythoner-Alan-lee closed 2 years ago

pythoner-Alan-lee commented 6 years ago

Process RefreshRun: Traceback (most recent call last): File "F:\python3\lib\multiprocessing\process.py", line 258, in _bootstrap self.run() File "F:\python3\lib\multiprocessing\process.py", line 93, in run self._target(*self._args, self._kwargs) File "..\Schedule\ProxyRefreshSchedule.py", line 97, in run main() File "..\Schedule\ProxyRefreshSchedule.py", line 77, in main p = ProxyRefreshSchedule() File "..\Schedule\ProxyRefreshSchedule.py", line 40, in init ProxyManager.init(self) File "..\Manager\ProxyManager.py", line 32, in init self.db = DbClient() File "..\DB\DbClient.py", line 58, in init self.config = GetConfig() File "..\Util\GetConfig.py", line 30, in init self.config_file.read(self.config_path) File "F:\python3\lib\configparser.py", line 697, in read self._read(fp, filename) File "F:\python3\lib\configparser.py", line 1015, in _read for lineno, line in enumerate(fp, start=1): UnicodeDecodeError: 'gbk' codec can't decode byte 0xbf in position 2: illegal mu ltibyte sequence Process ProxyApiRun: Traceback (most recent call last): File "F:\python3\lib\multiprocessing\process.py", line 258, in _bootstrap self.run() File "F:\python3\lib\multiprocessing\process.py", line 93, in run self._target(*self._args, *self._kwargs) File "..\Api\ProxyApi.py", line 88, in run config = GetConfig() File "..\Util\GetConfig.py", line 30, in init self.config_file.read(self.config_path) File "F:\python3\lib\configparser.py", line 697, in read self._read(fp, filename) File "F:\python3\lib\configparser.py", line 1015, in _read for lineno, line in enumerate(fp, start=1): UnicodeDecodeError: 'gbk' codec can't decode byte 0xbf in position 2: illegal mu ltibyte sequence Process ValidRun: Traceback (most recent call last): File "F:\python3\lib\multiprocessing\process.py", line 258, in _bootstrap self.run() File "F:\python3\lib\multiprocessing\process.py", line 93, in run self._target(self._args, self._kwargs) File "..\Schedule\ProxyValidSchedule.py", line 71, in run p = ProxyValidSchedule() File "..\Schedule\ProxyValidSchedule.py", line 31, in init ProxyManager.init(self) File "..\Manager\ProxyManager.py", line 32, in init self.db = DbClient() File "..\DB\DbClient.py", line 58, in init self.config = GetConfig() File "..\Util\GetConfig.py", line 30, in init self.config_file.read(self.config_path) File "F:\python3\lib\configparser.py", line 697, in read self._read(fp, filename) File "F:\python3\lib\configparser.py", line 1015, in _read for lineno, line in enumerate(fp, start=1): UnicodeDecodeError: 'gbk' codec can't decode byte 0xbf in position 2: illegal mu ltibyte sequence

不知道怎么解决,用了encoding="utf-8"也不行

jhao104 commented 6 years ago

@pythoner-Alan-lee Config.ini 文件不能有中文

pythoner-Alan-lee commented 6 years ago

试了一下,删了Config.ini里的中文也是不行,附上我配置的Config.ini ;[DB] ;Configure the database information ;type: SSDB/REDIS/MONGODB if use redis, only modify the host port,the type should be SSDB type = SSDB host = localhost port = 6379 ;port = 8888 name = proxy

;[ProxyGetter] ;register the proxy getter function freeProxyFirst = 1 freeProxySecond = 1 ;freeProxyThird = 1 freeProxyFourth = 1 freeProxyFifth = 1 freeProxySixth = 1 freeProxySeventh = 1 freeProxyEight = 1 ;foreign website, outside the wall ;freeProxyWallFirst = 1 ;freeProxyWallSecond = 1

;[HOST] ip = 127.0.0.1 port = 5010

jhao104 commented 6 years ago

@pythoner-Alan-lee 你的Config.ini文件是不是用windows自带文本编辑器打开过?
你用其他文本编辑器打开看看编码 image

如果用win自带的文本编辑器打开过会变成UTF-8+,转成utf-8就行了

pythoner-Alan-lee commented 6 years ago

OK了,谢谢你,成功运行了。

SharonMina commented 5 years ago

linux下用 vim打开,然后 :set fileencoding=utf-8 保存即可,如果还出错,保存后退出,多尝试几次。