不推荐使用imp模块以支持importlib

Not*_*bby 6 python imp pandas python-importlib

我在我的代码和熊猫中使用pandas它们使用了imp结节.现在我收到以下错误/警告

C:\Users\refaelc\AppData\Local\Temp\collection_id-96deaf03-9b39-46c0-a843-63f6101481c1-5289121858290797008.csv
Step07: Compare the downloaded and the template files
C:\Users\refaelc\AppData\Local\Continuum\Anaconda3\lib\importlib\_bootstrap.py:205: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
  return f(*args, **kwds)
C:\Users\refaelc\AppData\Local\Continuum\Anaconda3\lib\site-packages\_pytest\assertion\rewrite.py:7: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
Item is missing from collections - int
Run Code Online (Sandbox Code Playgroud)

现在我做了一些搜索并意识到imp模块正在被importlib模块取代.我更新了Panda,但没有用.我似乎不太可能需要改变Panda的包裹代码.

有什么想法/修复?

Khu*_*alm 5

我也遇到了同样的问题,但是我的情况是与sklearn Library有关,为了解决警告,这是我所做的(您也可以这样做):

  1. 使用cloudpickle.py该位置存在的具有命名权限的编辑打开文件\sklearn\externals\joblib\externals\cloudpickle\cloudpickle.py
  2. 更换import impfrom imp import find_moduleimport importlib在文件的顶部。
  3. 找到名为函数find_module并更换线 file, path, description = find_module(path)file, path, description = importlib.utils.find_spec(path)

所以,综上所述,您必须更换的提imp moduleimportlib它引发错误的文件中。您的文件rewrite.py位于C:\Users\refaelc\AppData\Local\Continuum\Anaconda3\lib\site-packages\_pytest\assertion\rewrite.py

  • 我必须将其更改为“importlib.util.find_spec(path)”,遵循https://docs.python.org/3/library/importlib.html#importlib.util.find_spec (2认同)