Open Pablitosi4 opened 3 months ago
Try just replacing every instance of the string ConfigParser
in your code with configparser
…
Try just replacing every instance of the string
ConfigParser
in your code withconfigparser
…
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
pip list
Package Version configparser 6.0.1 dbus-python 1.2.18 et-xmlfile 1.1.0 onboard 1.4.1 openpyxl 3.1.2 pip 22.1 pycairo 1.20.1 PyGObject 3.42.1 setuptools 59.6.0 six 1.16.0 urllib3 1.26.9 wheel 0.37.1
echo "import configparser" > file.py
- # configparser
python3 --version
Python 3.10.4
python3 file.py ; echo -e "\nresult: $?"
# py3; echo $?result: 0
python --version
Python 2.7.18
python file.py ; echo -e "\nresult: $?"
# py2; echo $?Traceback (most recent call last):
File "file.py", line 1, in
result: 1
echo "import ConfigParser" > file.py
# ConfigParser
python file.py ; echo -e "\nresult: $?"
# py2; echo $?
result: 0
python3 file.py ; echo -e "\nresult: $?"
# py3; echo $?_Traceback (most recent call last):
File "/home/user/file.py", line 1, in
result: 1_
Do I need to pip install configparser
in both Python2 and Python3?
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?