20

I'm using pandas in my code and in pandas they use the imp nodule. Now I get the following error/warnning

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

Now I did some searching and realized that the imp module is being replaced by the importlib module. I updated Panda and that didn't work. It seemed unlikely that I'll need to change Panda's package code.

Any thoughts/fixes?

NotSoShabby
  • 3,316
  • 9
  • 32
  • 56

2 Answers2

16

I was also facing the same issue but in my case, it was with sklearn Library and in order to fix the warning this is what I did (you can also try this):

  1. Open the file with editing privileges named cloudpickle.py which is present at this location \sklearn\externals\joblib\externals\cloudpickle\cloudpickle.py
  2. replace import imp with import importlib at the top of the file.
  3. find function named find_module and replace the line file, path, description = imp.find_module(part, path) with file, path, description = importlib.utils.find_spec(path)

So, in conclusion, you have to replace mention of imp module with importlib in the file which is throwing the error. In your case the file is rewrite.py present at C:\Users\refaelc\AppData\Local\Continuum\Anaconda3\lib\site-packages\_pytest\assertion\rewrite.py

Khushhal
  • 645
  • 11
  • 18
0

importlib.util.find_spec(path) Instead of utils, should work

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 05 '22 at 18:13