You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Importing imp in standard_library raises a PendingDeprecationWarning #246
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
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.
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?
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
Activity
Suppress a warning due to python-future
gGonz commentedon Feb 15, 2020
Any hope to get this fixed? Still happening after 3 years.
elderlabs commentedon Nov 21, 2021
Assuming no one has plans to fix this? Currently tracking the source of a
DeprecationWarningand found this along the way.Editing in an idea here, but what's the potential cost of importing
impin conditions requiring Python2 only, with a workaround for situations requiring it in Python3? Python 3.12 will drop all support forimp. Given there are several libraries in the wild that actively depend onpython-futurefor 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-futuredirectly, but rather as a dependency of python-whois. Working out a solution on my own risks breaking something, as I'm not usingpython-futuredirectly. Thanks.elderlabs commentedon 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 commentedon May 11, 2023
The
impmodule has now been removed from Python 3.12.impmodule python/cpython#98573Python 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? Theimpdocs have suggestions on what to use to replace each function and constant.yonran commentedon Oct 11, 2023
For people googling, in python 3.12, importing
future.standard_libraryraises “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.parseurllib.error-->six.moves.urllib.errorurllib.parse-->six.moves.urllib.parsedbm.ndbm-->six.moves. dbm_ndbmhttp.server-->six.BaseHTTPServer,six.CGIHTTPServer, orsix.SimpleHTTPServertkinter.filedialog-->six.tkinter_tkfiledialogtkinter.simpledialog-->six.tkinter_simpledialogxmlrpc.server-->six.xmlrpc_server