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
I'm working on the migration of my scripts from py2 to py3. So using the futurize tool.
as mentioned in the feature section of the git page "future.builtins package (also available as builtins on Py2) provides backports and remappings for 20 builtins with different semantics on Py3 versus Py2" but the case is builtins is not available in python2.7
`Python 2.7.17 (default, Feb 5 2022, 02:29:07)
[GCC 9.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
from builtins import str
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named builtins
`
Since I used futurize tool, it imported "from builtins import objects" in my script but now this compatible with py3 not py2. how can I make compatible with both version for the builtin module. please help.
The text was updated successfully, but these errors were encountered:
I ran into the same problem. After lots of digging I noticed that the package is installed in the /usr/lib/python3/dist-packages/ directory but not in the /usr/lib/python2.7/dist-packages/ directory.
When Python 2.7 went EOL pip stopped working for Python 2 packages.
In order to install this package for Python 2.7:
I downloaded the package as python-future-master.zip from the main code page
I created, as root, the /usr/lib/python2.7/dist-packages/future directory
I extracted the python-future-master.zip file's /src/future directory to /usr/lib/python2.7/dist-packages/future
I was then able to import builtins in Python 2.7.
Edit: Actually "from future import builtins" was what worked.
To import from builtins one must use: from future.builtins import bytes
I'm working on the migration of my scripts from py2 to py3. So using the futurize tool.
as mentioned in the feature section of the git page "future.builtins package (also available as builtins on Py2) provides backports and remappings for 20 builtins with different semantics on Py3 versus Py2" but the case is builtins is not available in python2.7
`Python 2.7.17 (default, Feb 5 2022, 02:29:07)
[GCC 9.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Since I used futurize tool, it imported "from builtins import objects" in my script but now this compatible with py3 not py2. how can I make compatible with both version for the builtin module. please help.
The text was updated successfully, but these errors were encountered: