🌐
GitHub
github.com › PiotrDabkowski › Js2Py › issues › 21
Unable to import js2py · Issue #21 · PiotrDabkowski/Js2Py
October 6, 2015 - >>> import Js2Py.js2py Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/Js2Py/js2py/__init__.py", line 67, in <module> from js2py.evaljs import * ImportError: No module named 'js2py' >>> sys.path.append('/Users/Js2Py') >>> import js2py Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/Js2Py/js2py/__init__.py", line 67, in <module> from js2py.evaljs import * File "/Users/Js2Py/js2py/evaljs.py", line 56 exec DEFAULT_HEADER in self._context ^ SyntaxError: Missing parentheses in call to 'exec' >>> operated on python3.4 on Mac ·
Author   ghost
🌐
Python Forum
python-forum.io › thread-27639.html
Js2Py module not found problem
I am just doing some testing for js2py and i wrote some simple code which should output 6, however whenever i try to run it, it says there is no module called js2py, what am i missing? Here's the code: import js2py code1 = 'function f(x) {return x +...
Discussions

Import module not found error
Hi there, Once i try translating js to py via js2py.translate_file and write from & import the "to be created output file". it gives me an error: ModuleNotFoundError: No module named " " or unable ... More on github.com
🌐 github.com
0
July 3, 2020
python 3.x - Import a javascript function in js2py - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Ask questions, find answers and collaborate at work with Stack Overflow for Teams More on stackoverflow.com
🌐 stackoverflow.com
How to import javascript code in python with variable? - Stack Overflow
I have file javascript and python, I want to call javascript function in python code with send variable from python. example my javascript file var msg = 'this is the encrypt key, very long charact... More on stackoverflow.com
🌐 stackoverflow.com
December 4, 2020
jupyter notebook - "ImportError: No module named" when trying to run Python script - Stack Overflow
I'm trying to run a script that launches, amongst other things, a python script. I get a ImportError: No module named ..., however, if I launch ipython and import the same module in the same way t... More on stackoverflow.com
🌐 stackoverflow.com
🌐
RoseIndia
roseindia.net › answers › viewqa › pythonquestions › 127269-ModuleNotFoundError-No-module-named-Js2Py.html
ModuleNotFoundError: No module named 'Js2Py'
After the installation of Js2Py python library, ModuleNotFoundError: No module named 'Js2Py' error will be solved.
🌐
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
🌐
GitHub
github.com › PiotrDabkowski › Js2Py › issues › 251
ModuleNotFoundError: No module named 'js2py' · Issue #251 · PiotrDabkowski/Js2Py
Hi, I'm encountering trouble when trying to import js2py with the line ´import js2py´ in one of my scripts. I've tried installing different versions of the library with pip, and even tried directly from source, but my script has no knowl...
🌐
GitHub
github.com › PiotrDabkowski › Js2Py › issues › 209
Import module not found error · Issue #209 · PiotrDabkowski/Js2Py
July 3, 2020 - Hi there, Once i try translating js to py via js2py.translate_file and write from & import the "to be created output file". it gives me an error: ModuleNotFoundError: No module named " " or unable ...
Author   Daniyaldehleh
🌐
GitHub
github.com › Gab0 › japonicus › issues › 82
Can't run japonicus · Issue #82 · Gab0/japonicus
February 18, 2018 - Requirement already satisfied: js2py in /usr/local/lib/python3.5/dist-packages Requirement already satisfied: tzlocal>=1.2 in /usr/local/lib/python3.5/dist-packages (from js2py) Requirement already satisfied: six>=1.10 in /usr/lib/python3/dist-packages (from js2py) Requirement already satisfied: pyjsparser>=2.5.1 in /usr/local/lib/python3.5/dist-packages (from js2py) Requirement already satisfied: pytz in /usr/local/lib/python3.5/dist-packages (from tzlocal>=1.2->js2py)
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

🌐
GitHub
github.com › PiotrDabkowski › Js2Py
GitHub - PiotrDabkowski/Js2Py: JavaScript to Python Translator & JavaScript interpreter written in 100% pure Python🚀 Try it online:
They are generally not a big issue in practice. In practice more problematic are minor edge cases that unfortunately sometimes do happen. Please report a bug if you find one. Js2Py was able to successfully translate and run huge JS libraries like Babel (100k+ loc), esprima, crypto-js and more.
Starred by 2.6K users
Forked by 276 users
Languages   JavaScript 65.1% | Python 34.9%
Find elsewhere
Top answer
1 of 16
254

This issue arises due to the ways in which the command line IPython interpreter uses your current path vs. the way a separate process does (be it an IPython notebook, external process, etc). IPython will look for modules to import that are not only found in your sys.path, but also on your current working directory. When starting an interpreter from the command line, the current directory you're operating in is the same one you started ipython in. If you run

import os
os.getcwd() 

you'll see this is true.

However, let's say you're using an ipython notebook, run os.getcwd() and your current working directory is instead the folder in which you told the notebook to operate from in your ipython_notebook_config.py file (typically using the c.NotebookManager.notebook_dir setting).

The solution is to provide the python interpreter with the path-to-your-module. The simplest solution is to append that path to your sys.path list. In your notebook, first try:

import sys
sys.path.append('my/path/to/module/folder')

import module_of_interest

If that doesn't work, you've got a different problem on your hands unrelated to path-to-import and you should provide more info about your problem.

The better (and more permanent) way to solve this is to set your PYTHONPATH, which provides the interpreter with additional directories look in for python packages/modules. Editing or setting the PYTHONPATH as a global var is os dependent, and is discussed in detail here for Unix or Windows.

2 of 16
20

Just create an empty python file with the name __init__.py under the folder which showing error, while you running the python project.

🌐
GitHub
github.com › PiotrDabkowski › Js2Py › issues › 226
AssertionError: Could not install the required module: · Issue #226 · PiotrDabkowski/Js2Py
I even can't call npm via the terminal, after running the script. It gives me this error: zsh: command not found: npm So then I have to remove node completely and reinstall it again to use js2py again.
🌐
Realtycampaigns
realtycampaigns.com › sportsman-pocket-opnx › modulenotfounderror:-no-module-named-'js2py'-6ba5cd
modulenotfounderror: no module named 'js2py'
You can rename the file utils.py to something else ModuleNotFoundError in Python: module! Environment not successfully getting activating: can not import name ' a ' Absolute vs modulenotfounderror: no module named 'js2py'. Johnny fundamentally, aguish ModuleNotFoundError: No module named 'gurobipy ' 0 you are using pip as your package....
🌐
GitHub
github.com › PiotrDabkowski › Js2Py › issues › 69
Issue when using from Kodi plugin · Issue #69 · PiotrDabkowski/Js2Py
January 4, 2017 - When I try to use: import js2py util.info(js2py.eval_js('console.log( "Hello World!" )')) I encountered: Error Type: Error Contents: No module named js2py.pyjs Traceback (most recent call last): File "C:\U...
Author   zbyna
🌐
Reddit
reddit.com › r/learnpython › why am i getting a modulenotfound error when i have it installed
r/learnpython on Reddit: Why am I getting a ModuleNotFound error when I have it installed
January 8, 2022 -

Hey there! I've been getting so frustrated trying to figure this out. I keep getting ModuleNotFound errors for modules that I most definitely have installed, this case requests. I tried moving the install around and making sure it was in the same folder I'm working on my python file from but to no avail. I'm sure I'm missing something stupid. The traceback error is as follows:

Traceback (most recent call last):

File "/Users/redacted/Desktop/cxt_copy/zd_test.py", line 5, in <module>

import requests

ModuleNotFoundError: No module named 'requests'

I'm relying on this for work so any help is much appreciated!

EDIT: I'm on a Mac, using Sublime Text Editor to run Python, have Python3 installed and I installed requests using pip install via the terminal.

🌐
Safe Community
community.safe.com › home › forums › fme form › data › getting the error: python exception : no module named parser
Getting the error: Python Exception : No module named parser | Community
November 28, 2017 - fme\\python\\js2py\\translators\\pyjsparser.pyc · fme\\python\\js2py\\translators\\pyjsparserdata.pyc · fme\\python\\js2py\\translators\\std_nodes.pyc · These are the old .pyc files from the older FME installs. This should resolve the issue. Please let me know.
🌐
Safe Community
community.safe.com › s › question › 0D54Q000080h81VSAQ › python-exception-no-module-named-parser
Python Exception: No module named parser - FME Community
November 28, 2017 - fme\\python\\js2py\\translators\\pyjsparser.pyc · fme\\python\\js2py\\translators\\pyjsparserdata.pyc · fme\\python\\js2py\\translators\\std_nodes.pyc · Thanks. That worked. 31,819 · Posts · 120,865 · Replies · 39,453 · Members · Powered by Gainsight ·
🌐
Career Karma
careerkarma.com › blog › python › python modulenotfounderror solution
Python ModuleNotFoundError Solution | Career Karma
December 1, 2023 - A ModuleNotFoundError is raised when Python cannot successfully import a module.
🌐
Real Python
realpython.com › ref › builtin-exceptions › modulenotfounderror
ModuleNotFoundError | Python’s Built-in Exceptions – Real Python
ModuleNotFoundError is a built-in exception that Python raises when an import statement fails to find a specified module.