imports do not work in script inside html and from browser does not work in external files
See original GitHub issueI was trying to move your example calculator code to an external .py file, but ‘from browser’ did not work, since there’s no such library. I installed ‘pip install brython’, which did not help.
Then I tried importing a different python class inside the html python script, however, it did not work either. The other file lies in the same root directory where the requesting code is. What can be wrong?
`
<body onload="brython()"> <script type="text/python"> from calculator import * # this causes a ModuleNotFoundError: calculator from browser import document, html </script> </body> `Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
External javascript file not working in HTML file - Stack Overflow
The first solution is to put your JS file after the second one is to put the function call inside the window onload...
Read more >How to Load External JavaScript Files From the Browser ...
Here is how to import JavaScript without a <script> tag directly from Firefox or Chrome's development console.
Read more >JavaScript modules - MDN Web Docs
This guide gives you all you need to get started with JavaScript module syntax.
Read more >EP33 - Importing JavaScript into HTML via Script tag
Importing an external JavaScript file into your HTML page ... This will cause issues and will likely end in your script NOT being...
Read more >HTML script src Attribute - W3Schools
If you want to run the same JavaScript on several pages in a web site, you should create an external JavaScript file, instead...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I close the issue, assuming that the script runs when loaded from a web server. If it’s not the case don’t hesitate to reopen it.
To avoid the formatting problem in this issue tracker, you should use the markdown syntax for code, here put the code between lines starting with ```