Python腳本報錯:DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working import pymssql


報錯信息:

monitor_mssql.py:10: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working
import pymssql

 

 

這種 warning 就是快過期的不向后兼容的語法做了個警告。

解決辦法
1. 更新 pymssql 這個警告的庫, 一般有人維護的話, 作者會因為這 issue 更新版本。

2. 注釋掉這個告警模塊,一般不建議。

3. 調整導入包的寫法。

# from collections import Iterable   ---這是會報警告的用法
from collections.abc import Iterable ---這是不會報警告的用法
print(isinstance('abc', Iterable))

4. 直接屏蔽這個提示。在前面加兩行代碼:import warnings ...

import warnings
warnings.simplefilter('ignore', DeprecationWarning)
import pymssql

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM