🌐
GitHub
github.com › PiotrDabkowski › Js2Py
GitHub - PiotrDabkowski/Js2Py: JavaScript to Python Translator & JavaScript interpreter written in 100% pure Python🚀 Try it online:
JavaScript to Python Translator & JavaScript interpreter written in 100% pure Python🚀 Try it online: - PiotrDabkowski/Js2Py
Starred by 2.6K users
Forked by 278 users
Languages   JavaScript 65.1% | Python 34.9%
🌐
PyPI
pypi.org › project › Js2Py
Js2Py
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
People also ask

Is Js2Py popular?
The python package Js2Py receives a total · of 290,230 weekly downloads. As · such, Js2Py popularity was classified as · an · influential project. Visit the · popularity section · on Snyk Advisor to see the full health analysis.
🌐
snyk.io
snyk.io › advisor › python packages › js2py
Js2Py - Python Package Health Analysis | Snyk
Is Js2Py safe to use?
Security issues were found while scanning the · latest version of Js2Py, and a total of · 1 vulnerabilities were · detected. It is highly advised to conduct a security review before · using this package. View the full · security scan results.
🌐
snyk.io
snyk.io › advisor › python packages › js2py
Js2Py - Python Package Health Analysis | Snyk
Is Js2Py well maintained?
We found indications that Js2Py is an · Inactive project. See the full · package health analysis · to learn more about the package maintenance status.
🌐
snyk.io
snyk.io › advisor › python packages › js2py
Js2Py - Python Package Health Analysis | Snyk
🌐
PyPI
pypi.org › project › Js2Py-3.13
Js2Py-3.13 · PyPI
JavaScript to Python Translator & JavaScript interpreter written in 100% pure Python.
      » pip install Js2Py-3.13
    
Published   Feb 07, 2025
Version   0.74.1
🌐
Rapid7
rapid7.com › db › modules › exploit › linux › http › pyload_js2py_cve_2024_39205
Pyload RCE (CVE-2024-39205) with js2py sandbox ...
The vulnerability allows for an attacker to obtain a reference to a python object in the js2py environment enabling them to escape the sandbox, bypass pyimport restrictions and execute arbitrary commands on the host. At the time of writing no patch has been released, version 0.74 is the latest version of js2py which was released Nov 6, 2022.
🌐
Snyk
snyk.io › advisor › js2py › js2py code examples
Top 5 Js2Py Code Examples | Snyk
import js2py import datetime now = datetime.datetime.now # the line below will # - build a 'compilation plan' by substituting strings and constants with placeholders # - then build the ast and emit the python code from that compilation plan # - then substitute back in the constants # This causes some regex overhead, but for js code with similar structure # subsequent translate_js calls are 20 times faster js2py.translate_js('name == "Robert" && age == 46', use_compilation_plan=True) # this lines below will re-use the compilation plan already laid out by the # statement above js2py.translate_js
🌐
Anaconda.org
anaconda.org › conda-forge › js2py
js2py - Conda
View packages from the conda-forge channel on Anaconda.org.
🌐
YouTube
youtube.com › watch
Python 3 Script to Run Javascript Code Using js2py Library in ...
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
🌐
Piter
piter.io › projects › js2py
Home - Piotr Dabkowski
This domain was recently registered at Namecheap.com. Please check back later
Find elsewhere
🌐
Snyk
snyk.io › advisor › python packages › js2py
Js2Py - Python Package Health Analysis | Snyk
JavaScript to Python Translator & JavaScript interpreter written in 100% pure Python. Visit Snyk Advisor to see a full health score report for Js2Py, including popularity, security, maintenance & community analysis.
🌐
Anaconda.org
anaconda.org › anaconda › js2py
Js2Py | Anaconda.org
Translates JavaScript to Python code. Js2Py is able to translate and execute virtually any JavaScript code. Js2Py is written in pure python and does not have any dependencies.
🌐
GitHub
github.com › int3 › js2py
GitHub - int3/js2py: A Javascript-to-Python translation assistant.
A Javascript-to-Python translation assistant. Contribute to int3/js2py development by creating an account on GitHub.
Author   int3
🌐
FreshPorts
freshports.org › devel › py-Js2Py
FreshPorts -- devel/py-Js2Py: JavaScript to Python translator and interpreter
Translates JavaScript to Python code. Js2Py is able to translate and execute virtually any JavaScript code. Js2Py is written in pure python and does not have any dependencies. Basically an implementation of JavaScript core in pure python.
🌐
piwheels
piwheels.org › project › js2py
piwheels - Js2Py
The piwheels project page for Js2Py: JavaScript to Python Translator & JavaScript interpreter written in 100% pure Python.
Top answer
1 of 2
4

There is a new alternative to js2py called PythonMonkey which lets you import JavaScript files directly from Python and execute them.

https://github.com/Distributive-Network/PythonMonkey

JavaScript numar.js file:

module.exports = function numar(){
    return 1; //return 1 if the checkbox is
}

Python main.py file:

import pythonmonkey as pm
numar = pm.require('./numar')

print(numar()) # this outputs "1.0"
2 of 2
1

This is still an issue in js2py and this link may help you. https://github.com/PiotrDabkowski/Js2Py/issues/123#issuecomment-866218046

The only way to solve this is to modify translated file.

# translate myfunction.js, numar.js files to python
import js2py

js2py.translate_file('numar.js', 'numar.py')
js2py.translate_file('myfunction.js', 'myfunction.py')
// myfunction.js
var numar = require("./numar");
function myfunction() {
  var b = numar();
  return b;
}
// numar.js
function numar(){
    return 1; //return 1 if the checkbox is
}
# then modify translated myfunction.py file like this
__all__ = ['myfunction']

# Don't look below, you will not understand this Python code :) I don't.

from js2py.pyjs import *
from numar import numar
# setting scope
var = Scope( JS_BUILTINS )
set_global_object(var)

# Code follows:
var.registers(['numar', 'myfunction'])
@Js
def PyJsHoisted_myfunction_(this, arguments, var=var):
    var = Scope({'this':this, 'arguments':arguments}, var)
    var.registers(['b'])
    var.put('b', var.get('numar')())
    return var.get('b')
PyJsHoisted_myfunction_.func_name = 'myfunction'
var.put('myfunction', PyJsHoisted_myfunction_)
var.put('numar', numar.numar)
pass
pass


# Add lib to the module scope
myfunction = var.to_python()
# import in your code
from myfunction import myfunction

print(myfunction.myfunction())

You can find the code here.

https://github.com/lacmansoftware/python-js2py-require-solution

🌐
deps.dev
deps.dev › pypi › js2py
js2py | PyPI
November 6, 2022 - You need to enable JavaScript to run this app
🌐
SUSE Package Hub
packagehub.suse.com › packages › python3-Js2Py
SUSE Package Hub - python3-Js2Py
Js2Py, basically an implementation of the JavaScript core, is written in pure Python.
🌐
Gentoo
packages.gentoo.org › packages › dev-python › js2py
dev-python/js2py – Gentoo Packages
JavaScript to Python Translator & JavaScript interpreter in Python · http://piter.io/projects/js2py
🌐
Stack Overflow
stackoverflow.com › questions › 69956547 › javascript-to-python-using-js2py
JavaScript to Python (Using JS2PY) - Stack Overflow
import js2py hasCode = js2py.eval_js('function hashCode(s) {let h = 0; for (let i = 0; i < s.length; i++) {h = (Math.imul(31, h) + s.charCodeAt(i)) | 0;} return h;}') getSeed = js2py.eval_js('function getSeed(s) {let x = BigInt(hashCode(s)); if (/^[\-\+0-9]*$/.test(s)) {try {let y = BigInt(s); if (BigInt.asIntN(64, y) !== y) {throw RangeError();} x = y;} catch (err) {}} return { high: x >> 32n, low: BigInt.asIntN(32, x) };}') output = js2py.eval_js('function output() {let seed = -734744700160476640; print("Copy this output - " + seed.high, seed.low);}') output()
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-run-javascript-from-python
How to Run JavaScript from Python ? - GeeksforGeeks
April 6, 2023 - In this article, we'll discuss how to run a javascript file with Python. For this, we'll use the JS2PY(Javascript Runtime in Pure Python) Python module. JS2PY works by translating JavaScript directly into Python.