python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument解決辦法

我是在使用bert==0.09的時候,遇到這個問題

原因:

numpy和h5py版本兼容問題,網上說h5py 官方已修復合併到 master 分支,但是還沒發新版,在發版之前可以用降級 numpy 的方法跳過這個問題。

所以我找到適合我的應用場景的一組版本,問題就解決了。

解決:

pip3 install --upgrade h5py==2.9.0
pip3 install --upgrade numpy==1.14.2
# 備註:肯定有其它的版本配合,我這沒有過多測試

# 另:Linux下解決,mac下 仍然會有報錯

bug還原

#首先安裝bert==0.09
pip3 install bert==0.09
# 然後,在查看幫助命令的時候報錯:
bert-base-serving-start --help

bug顯示:

/Users/Davide/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/Users/Davide/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/Users/Davide/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:528: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/Users/Davide/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:529: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/Users/Davide/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:530: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/Users/Davide/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:535: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
/Users/Davide/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters

重點是:

h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.

然後重新修改下版本後就沒問題了!

注意:

        系統環境下,可能有其它的包依賴numpy,在切換numpy版本時,需要注意有木有版本ERROR,如我的環境中就有這個問題:

所以這時候,一定要做好取捨,因爲h5py報錯,也只是 FutureWarning,是在未來的版本中會不支持,但目前並不影響程序運行,所以,還是要根據實際情況來選擇,或者還有一個辦法,分多套虛擬環境進行部署。

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