Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation warning about imp module #1256

Closed
melund opened this issue Oct 5, 2018 · 6 comments
Closed

Deprecation warning about imp module #1256

melund opened this issue Oct 5, 2018 · 6 comments

Comments

@melund
Copy link

melund commented Oct 5, 2018

When using projects that rely on pywin32 I get a deprecation warning:

pywintypes.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp, sys, os

I am using pywin32 from the conda-forge conda channel.

$ conda list pywin32
# packages in environment at C:\Users\mel\anaconda3:
#
# Name                    Version                   Build  Channel
pywin32                   224             py36hfa6e2cd_1000    conda-forge
@carlodri
Copy link

carlodri commented Jul 1, 2019

same happening to me here today, during a pytest run, using pywin32 v221:

C:\Miniconda3x64\lib\site-packages\win32\lib\pywintypes.py:2
  C:\Miniconda3x64\lib\site-packages\win32\lib\pywintypes.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import imp, sys, os

@carlodri
Copy link

carlodri commented Jul 1, 2019

the problem still occurs with pywin32 v224

@webknjaz
Copy link

webknjaz commented Sep 4, 2019

Happening with pytest when filterwarnings is set to error: https://ci.appveyor.com/project/CherryPy/cherrypy/builds/27163909/job/0r572kw6vx6g88a6?fullLog=true#L512

@mhammond ^

webknjaz added a commit to cherrypy/cherrypy that referenced this issue Sep 4, 2019
@JattMones
Copy link

JattMones commented Sep 9, 2019

Without rewriting the existing code, we'd have to find importLibs equivalents to imps "C_EXTENSION, load_module, load_dynamic, and get_suffixes" functions and keywords. Most of these are found in the loop that deals with handling non-windows systems (all except for the load_module). So if you are always running on windows, comment this section out, and replace the with the alternative for load_dynamic.

I believe that these might work (not tested):
imp.load_module = importlib.import_module
imp.load_dynamic = importlib.invalidate_caches(), importlib.import_module
imp.get_suffix = importlib.machinery.SOURCE_SUFFIXES (I'm pretty sure this one needs to be modified or is incorrect)
imp.C_EXTENSION = 3 (This may need to be modified depending on how we replace get_suffix.)

I'm getting the warning mentioned above when importing win10toast which uses pywin32. However, this file must not be crucial to win10toast, because I can simply remove imp from the import statements, the warning is removed, and everything still runs fine (in otherwords, pywintypes.py is never called). Until the win32 developers find alternatives for the current imp functions and keywords, this may be a temporary fix for you too.

The-Compiler added a commit to qutebrowser/qutebrowser that referenced this issue Nov 18, 2019
The-Compiler added a commit to qutebrowser/qutebrowser that referenced this issue Nov 22, 2019
The-Compiler added a commit to qutebrowser/qutebrowser that referenced this issue Nov 22, 2019
mick-id added a commit to mick-id/pywin32 that referenced this issue Dec 4, 2019
@brgirgis
Copy link

What is the ETA on this issue to be resolved?

@henrycjc
Copy link

henrycjc commented Mar 23, 2021

@brgirgis #1256 this has been resolved. I no longer get the warning in v300

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants