ImportError: No module named builtins

46

Solution 1

Solved a similar error in a separate situation by installing the package future.

sudo pip install future

It's not clear if your error occurs when running 2to3 or when trying to run the resulting code. If it is when running 2to3 it is likely because it's actually using python2 (the default) and thus if you haven't installed the future, builtins will be missing. Similarly if you are trying to run the resulting code with python2 the same error might occur.

Solution 2

The 2to3 tool generates code compatible with Python 3-only.

You're probably seeing that because you're running the converted code in Python 2.

If you want your code to be compatible with Python 2 and 3, you can do this instead:

try:
    import builtins
except ImportError:
    import __builtin__ as builtins
Share:
46

Related videos on Youtube

Td3S
Author by

Td3S

Updated on September 18, 2022

Comments

  • Td3S
    Td3S over 1 year

    *js code*
    //create variable for button control
    function Verify(){
    var user = document.getElementById["userLogin"]["email"].value;
    var pass = document.getElementById["userLogin"]["pass"].value;
    var btn= document.getElementById["userLogin"]["Login"].disabled;
    if  (user ==""){
    btn.disabled();
    }
    else if (pass ==""){
    btn.disabled();
    }
    else 
        btn.disabled = "false";
    }
    
    *css code*
    *{
      box-sizing: border-box;
    }
    head{
    text-emphasis-color: rgb(7, 7, 7);
    text-align: center;
    text-size-adjust: 22px;
    }
    
    body{
      background:#98fb98;
      color:#020202;
      line-height:1.6;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      padding:1em;
    }
    p{
      vertical-align: middle;
    }
    .container{
      max-width:1000px;
      margin-left:auto;
      margin-right:auto;
      padding:1em;
    }
    .brand{
      text-align: center;
    }
    
    .brand span{
      color:#fff;
    }
    
    .container{
      box-shadow: 0 0 20px 0 rgba(72,94,116,0.7);
    }
    
    .container{
      padding: 1em;
    }
    div{
    text-align:center;
    align-items: center;
    }
    
    .email{
      background:#f9feff;
    }
    
    .password{
    background:#f9feff;
    place-self: center;
    }
    .email{
    text-align: center;
    }
    .password{
    text-align: center;
    }
    .button{
    width:100%;
    border:#98fb98;
    background-color:#4c9a2a;
    }
    *html code*
    <!DOCTYPE html>
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title style ="font-color: #000000;">The Environmentalists</title>
        <p>
        <img src="icon.png" style = "width:1300px; height:400px; margin-left:auto;margin-right:auto;"></img>
        </P>
        <link rel ="stylesheet" href="styling.css">
    </head>
    <body>
        <div class="container">
            <h1 class="brand" style = "text-color: #000000;"><span>The Environmentalists</span></h1>
            <div class ="container">
            <form id="userLogin">
                <p>
                    <label>User</label>
                </p>
                <p>
                    <input type="email" name="email" id="email" required>
                </p>
                <p>
                    <label>Password</label>
                </p>
                <p>
                    <input type="text" name="password" id="password" required>
                </p>
                <p class="full">
                    <button type="signupbtn" value ="signup" style=" width:100%">SignUp</button>
                    <button type="button" value="Login" style=" width:100%" onclick = "location.href='map.html' ; Verify();" id = "Login" >Login</button>
                </p>
            </form>
            </div>
        </div>
    
    <script >
    index.js
    </script>
    </body>
    
    </html>
    • Helper
      Helper over 2 years
      You just want the code for allowing login as soon as all the fields are filled?
  • Td3S
    Td3S over 2 years
    //create variable for button control var user = document.getElementById("email").len; var pass = document.getElementById("Password").len; var btn= document.getElementById("Login").disabled = true; function Verify(){ if (user.len < 0){ btn.disabled(); } else if (pass.len < 0){ btn.disabled(); } else btn.disabled = "true"; } I've tried using this code now the button won't allow me through. below is the code for the button <button type="button" value="Login" style=" width:100%" onclick = "Verify(); location.href='map.html'; " id = "Login" >Login</button>