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

Importing imp in standard_library raises a PendingDeprecationWarning #246

Open
jfinkels opened this issue Oct 20, 2016 · 5 comments
Open

Comments

@jfinkels
Copy link

The imp package is pending deprecation in favor of importlib as of Python 3.4.

$ python3.5 -Wonce -c "import future.standard_library"
[...]/lib/python3.5/site.py:165: DeprecationWarning: 'U' mode is deprecated
  f = open(fullname, "rU")
[...]/lib/python3.5/site-packages/future/standard_library/__init__.py:66: PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp

The recommended alternative is described here.

skoranda added a commit to skoranda/pysaml2 that referenced this issue Dec 4, 2018
The python-future library is causing a warning about the
imp module being deprecated. See
PythonCharmers/python-future#246
This commit suppresses the warning.
@gGonz
Copy link

gGonz commented Feb 15, 2020

Any hope to get this fixed? Still happening after 3 years.

@elderlabs
Copy link

elderlabs commented Nov 21, 2021

Assuming no one has plans to fix this? Currently tracking the source of a DeprecationWarning and found this along the way.

Editing in an idea here, but what's the potential cost of importing imp in conditions requiring Python2 only, with a workaround for situations requiring it in Python3? Python 3.12 will drop all support for imp. Given there are several libraries in the wild that actively depend on python-future for the sole purpose of maintaining Py2 support, I'd like to find a fix in as efficient a manner as possible.

I'd work out a solution myself, but I'm not working with python-future directly, but rather as a dependency of python-whois. Working out a solution on my own risks breaking something, as I'm not using python-future directly. Thanks.

@elderlabs
Copy link

elderlabs commented Mar 31, 2023

Greetings again from the future. We're now in the days of Python 3.11, with Python 3.12's release looming ever closer. There is an open PR (#574) from 2019 to close this issue.

Is python-future dead? Once Python 3.12 releases, this project will be left in a forever broken state if not updated.
Please merge the pending PR.

EDIT 2: Updating my previous edit, it would seem the imp module deprecation is still present in 0.18.3. Will this ever be fixed?

@hugovk
Copy link

hugovk commented May 11, 2023

The imp module has now been removed from Python 3.12.

Python 3.12 will be in beta in two weeks, and set for release on 2023-10-02 and this library is one of the top 5,000 most-downloaded from PyPI.

Please could you upgrade to use importlib? The imp docs have suggestions on what to use to replace each function and constant.

@yonran
Copy link

yonran commented Oct 11, 2023

For people googling, in python 3.12, importing future.standard_library raises “ModuleNotFoundError: No module named 'imp'”:

ImportError: Failed to import test module: myfile
Traceback (most recent call last):
  …
  File "myfile.py", line 41, in <module>
    from future import standard_library
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/future/standard_library/__init__.py", line 65, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'

In my case, I resolved the error by replacing those imports that need future.standard_library.install_aliases() with six instead (see imports2):

  • urllib.parse --> six.moves.urllib.parse
  • urllib.error --> six.moves.urllib.error
  • urllib.parse -->six.moves.urllib.parse
  • dbm.ndbm --> six.moves. dbm_ndbm
  • http.server --> six.BaseHTTPServer, six.CGIHTTPServer, or six.SimpleHTTPServer
  • tkinter.filedialog --> six.tkinter_tkfiledialog
  • tkinter.simpledialog --> six.tkinter_simpledialog
  • xmlrpc.server --> six.xmlrpc_server

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

No branches or pull requests

6 participants