Introducing, PyScript! ⟨py⟩


i think you might have downloaded the zip. next, you have to build from source with nodejs.

use nvm to install nodejs, then run “nvm install 16; nvm use 16”

cd into the dir with the “package.json” file and run “npm install”

then run “npm run dev”

Got it working, thanks :slight_smile:

are these warnings normal?


i didnt get below message but got the server running fine

 Your application is ready~! 🚀

  - Local:      http://localhost:8080
  - Network:    Add `--host` to expose

also does it really run fully in the browser through webassembly? or is there any backend processing in the nodejs server?


pyscript does not use backend processing in nodejs or any other backend tech. once you build from source you can host in aws s3 or netlify or any other static content hosting system


The latest LTS version didn’t work. google suggested using 16.13.2 as it used older version of npm. That managed to get past ‘npm install’, however the next command ‘npm run dev’ introduced a new error:

(thank you for earlier reply)

let me look into this.

can you make an issue over at Issues · pyscript/pyscript · GitHub ?

1 Like

Hi, I love this project but I’m having an hard time trying to share data between Python and JavaScript.
I wrote a simple example but I’m not able to make it work.

I’d really appreciate some help, thank you!

<!DOCTYPE html>
    <link rel="stylesheet" href="" />
    <script defer src=""></script>
    <div id="div1"></div>
    <div id="div2"></div>

py_string = "This is a Python string!"

      var div1 = document.getElementById("div1");
      var div2 = document.getElementById("div2");
      var js_string = "This is a JavaScript string!";
      div1.innerHTML = js_string
      div2.innerHTML = py_string

from js import console

1 Like

To get JS variables into Python
We have to import the variable it self
As below:

from js import js_string <!-- Should import the variable -->
1 Like

Thank you that worked, how can I get Python variables into JS?

1 Like

Pretty much here is explained:
Until pyscript documentation is published read this for now:

Reading through this forum a lot of people seem to be misunderstanding the limitations of PyScript. Trying to use libraries that require access to system sockets, calls, or start processes.

While education is going to always be challenging with a library like this I wonder if it would make sense to highlight some common limitations on the front of the site itself? Like instead of using requests use pyfetch (or whatever library ends up being standardized, and a link to some documentation), and examples of things which can’t be done such as scanning user processes, or launching a new process, or connecting directly to sockets, etc…


the million dollar question.
on it claims:
Python with JavaScript: Bi-directional communication between Python and Javascript objects and namespaces”
lol whatever.

What do you mean? If you looking for “Bi-directional communication between Python and Javascript objects and namespaces” it is already solved by pyodide type conversion (see link above)

I Love this!!! :white_heart::white_heart::white_heart: Can’t wait to start using it and contributing!

How to decrease runtime process in pyscript?

I’m trying to connect to pinotdb using connect(host=url,port=80, path=query/sql, scheme=‘http’)
but it gives error.
Is there any possible way to connect to remote databases?

No, pintodb relies on requests which can not be run in PyScript as it relies on access to OS APIs / sockets and you can not do that in a web browser.

Maybe some day in the future someone will develop a drop in replacement to requests and you can monkey patch libraries like this, but for now the only way to connect to external APIs is to use something like pyfetch and code the logic of the interaction yourself.