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

**builtins** is not available in python2.7 #604

Open
prasanta2018 opened this issue Apr 4, 2022 · 1 comment
Open

**builtins** is not available in python2.7 #604

prasanta2018 opened this issue Apr 4, 2022 · 1 comment

Comments

@prasanta2018
Copy link

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.

@Mike-Allen
Copy link

Mike-Allen commented Apr 13, 2022

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
  • Time will tell if there are other problems.

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

No branches or pull requests

2 participants