Search code examples
pythonhtmlbrython

how to install externial moduels in brython


i am trying to install the module requests but it is not working

<html>
    <head>
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/brython.min.js"> </script> 
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/brython.js"> </script> 
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/brython_stdlib.js"> </script>
    </head>
    <body onload="brython()">
        <script type="text/python">
            import requests
        </script>
        <input id="zone"><button id="mybutton">click !</button>
   </body>
</html>

Solution

  • Something simple like import re probably works in your setup. https://docs.python.org/3/library/re.html

    But requests is not part of python's standard library. You will want to arrange for its dependencies separately. https://pypi.org/project/requests/


    https://pypi.org/project/brython-pack

    brython-pack packages your Python packages/files into a brython_modules.js.