I want to have a webpage run the Python program that connects to a Neo4j Database. The code must be run on the clientside device, and for parity reasons rewriting the code to be not Python is impossible due to parity reasons. Pyscript seems designed for this, so I was planning on using it. One problem, the moment I type "import neo4j" in my Python code the webpage refuses to load.
I thought it might be an issue with some other aspect of the code, so I started cutting down other things that could be affecting it, no progress. If I try the most minimal possible code with something random like pyjokes, I get: index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Recommended meta tags -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!-- PyScript CSS -->
<link rel="stylesheet" href="https://pyscript.net/releases/2024.1.1/core.css">
<!-- This script tag bootstraps PyScript -->
<script type="module" src="https://pyscript.net/releases/2024.1.1/core.js"></script>
</head>
<body>
<script type="py" src="./main.py" config="./pyscript.toml" terminal></script>
</body>
</html>
main.py:
import pyjokes
print("Hello, World!")
pyscript.toml:
packages = [ "pyjokes", ]
Which works fine, no problems. A quick swap to neo4j though gives: index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Recommended meta tags -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!-- PyScript CSS -->
<link rel="stylesheet" href="https://pyscript.net/releases/2024.1.1/core.css">
<!-- This script tag bootstraps PyScript -->
<script type="module" src="https://pyscript.net/releases/2024.1.1/core.js"></script>
</head>
<body>
<script type="py" src="./main.py" config="./pyscript.toml" terminal></script>
</body>
</html>
main.py:
import neo4j
print("Hello, World!")
pyscript.toml:
packages = [ "neo4j", ]
Which just hangs, never loading.
Any help or insight you could provide would be greatly appreciated!
The
packageskey inpy-configloads pure-Python packages from PyPI, or from the Pyodide pre-built repository, or wheels you've built yourself.It doesn't look like Neo4J provide a pure-Python wheel on PyPI, which means it won't necessarily load in PyScript.
The fact that the load hangs forever without an error message is likely a bug, and would be great to report to the PyScript team.