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
Hello, I am working on migrating a project from Python 2 to Python 3, ensuring compatibility so that it works on both Python 2 and Python 3. One of the problems I encountered is that Python 2 requires import ConfigParser, while Python 3 requires import configparser.
The functionality of the new version of the your project futurize, does not solve this problem.
Note that, as of v0.16.0, python-future no longer includes an alias for the configparser module because a full backport exists (see https://pypi.org/project/configparser/).
From this, I concluded that this issue is resolved by the tools of configparser's project.
After following your link to configparsers's project, I see:
This package is a backport of the refreshed and enhanced ConfigParser from later Python versions. To use the backport instead of the built-in version, simply import it explicitly as a backport:
`from backports import configparser`
To use the backport on Python 2 and the built-in version on Python 3, use the standard invocation:
`import configparser`
For detailed documentation consult the vanilla version at http://docs.python.org/3/library/configparser.html.
However, even after installing with pip install configparser, neither the code import configparser nor the code from backports import configparser works when running on Python 2.
Can you explain how to ensure configparser's compatibility between Python 2 and Python 3 without futurize's tools?
The text was updated successfully, but these errors were encountered:
Try just replacing every instance of the string ConfigParser in your code with configparser …
Thanks for such a quick response!
Unfortunately, your recommendation didn't help me. :(
Maybe I'm doing something wrong? I uninstalled confiparser and install again:
pip install configparser
Defaulting to user installation because normal site-packages is not writeable
Collecting configparser
Downloading configparser-6.0.1-py3-none-any.whl (19 kB)
Installing collected packages: configparser
Successfully installed configparser-6.0.1
Hello, I am working on migrating a project from Python 2 to Python 3, ensuring compatibility so that it works on both Python 2 and Python 3. One of the problems I encountered is that Python 2 requires
import ConfigParser
, while Python 3 requiresimport configparser
.The functionality of the new version of the your project futurize, does not solve this problem.
On your project website (https://python-future.org/imports.html), it is stated:
From this, I concluded that this issue is resolved by the tools of configparser's project.
After following your link to configparsers's project, I see:
However, even after installing with
pip install configparser,
neither the codeimport configparser
nor the codefrom backports import configparser
works when running on Python 2.Can you explain how to ensure configparser's compatibility between Python 2 and Python 3 without futurize's tools?
The text was updated successfully, but these errors were encountered: