Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
JS2PY install fails
-
Sorry, but I'm merely entering "pip install js2py' in Stash. Where should I make the change?
-
That text should be in the
setup.py
file inside the archive file: Js2Py-0.41.tar.gz -
I don't think that is the problem. The '100%' is just part of the literal definition:
'description='JavaScript to Python Translator & JavaScript interpreter written in 100% pure Python.' in the setup.py module.
If I ignore the setup failure and enter import js2py in the console, and I get "No module name pyjsparser"
-
Try typing your error message into Google and see what comes back... Based on your error message, I believe that Python is trying to interpolate the string in question.
You could try opening and issue on https://github.com/PiotrDabkowski/Js2Py and see if those folks have advice.
-
I tried the pip install on OSX and it worked fined. Perhaps pip install on Stash can't do this?
ihf$ pip install js2py
Collecting js2py
Downloading Js2Py-0.41.tar.gz (506kB)
100% |################################| 512kB 1.6MB/s
Collecting tzlocal>=1.2 (from js2py)
Downloading tzlocal-1.3.tar.gz
Collecting six>=1.10 (from js2py)
Downloading six-1.10.0-py2.py3-none-any.whl
Collecting pyjsparser>=2.4.5 (from js2py)
Downloading pyjsparser-2.4.5.tar.gz
Requirement already satisfied: pytz in /anaconda/lib/python2.7/site-packages (from tzlocal>=1.2->js2py)
Building wheels for collected packages: js2py, tzlocal, pyjsparser
Running setup.py bdist_wheel for js2py ... done
Stored in directory: /Users/ihf/Library/Caches/pip/wheels/24/50/10/50f3fc4c1c77e4f1bda05d28b1979259a357f5c06bd28e99af
Running setup.py bdist_wheel for tzlocal ... done
Stored in directory: /Users/ihf/Library/Caches/pip/wheels/80/19/a8/635ad9f4ad8a63b49d073c55cbca31fb5898ce2560ed145a69
Running setup.py bdist_wheel for pyjsparser ... done
Stored in directory: /Users/ihf/Library/Caches/pip/wheels/34/83/7d/0bdaeb6cf9b13ae9cd9aacd1dd0b59b91df81eb7a68938a035
Successfully built js2py tzlocal pyjsparser
Installing collected packages: tzlocal, six, pyjsparser, js2py
Found existing installation: six 1.8.0
Uninstalling six-1.8.0:
Successfully uninstalled six-1.8.0
Successfully installed js2py-0.41 pyjsparser-2.4.5 six-1.10.0 tzlocal-1.3 -
Try to install tzlocal and pyjsparser first. This is what happened on your Mac install.
-
Thanks, that helped (import js2py works) but if I try a simple test:
import js2py
js2py.eval_js('console.log( "Hello World!" )')I get a long Traceback.
-
Here is the Traceback in case anyone can make sense of it:
import js2py
js2py.eval_js('console.log("hello worlds")')
/private/var/mobile/Containers/Shared/AppGroup/637EEB4B-60E1-4F48-A8E5-66F2C7D9FCA2/Pythonista3/Documents/site-packages/js2py/constructors/time_helpers.py:10: UserWarning: Please install or fix tzlocal library (pip install tzlocal) in order to make Date object work better. Otherwise I will assume DST is in effect all the time
warnings.warn('Please install or fix tzlocal library (pip install tzlocal) in order to make Date object work better. Otherwise I will assume DST is in effect all the time')
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/mobile/Containers/Shared/AppGroup/637EEB4B-60E1-4F48-A8E5-66F2C7D9FCA2/Pythonista3/Documents/site-packages/js2py/evaljs.py", line 111, in eval_js
return e.eval(js)
File "/private/var/mobile/Containers/Shared/AppGroup/637EEB4B-60E1-4F48-A8E5-66F2C7D9FCA2/Pythonista3/Documents/site-packages/js2py/evaljs.py", line 180, in eval
self.execute(code, use_compilation_plan=use_compilation_plan)
File "/private/var/mobile/Containers/Shared/AppGroup/637EEB4B-60E1-4F48-A8E5-66F2C7D9FCA2/Pythonista3/Documents/site-packages/js2py/evaljs.py", line 175, in execute
exec(compiled, self._context)
File "<EvalJS snippet>", line 2, in <module>
File "/private/var/mobile/Containers/Shared/AppGroup/637EEB4B-60E1-4F48-A8E5-66F2C7D9FCA2/Pythonista3/Documents/site-packages/js2py/base.py", line 834, in call
return self.call(self.GlobalObject, args)
File "/private/var/mobile/Containers/Shared/AppGroup/637EEB4B-60E1-4F48-A8E5-66F2C7D9FCA2/Pythonista3/Documents/site-packages/js2py/base.py", line 1280, in call
return Js(self.code(*args))
File "/private/var/mobile/Containers/Shared/AppGroup/637EEB4B-60E1-4F48-A8E5-66F2C7D9FCA2/Pythonista3/Documents/site-packages/js2py/host/jseval.py", line 10, in Eval
local_scope = inspect.stack()[3][0].f_locals['var']
File "/var/containers/Bundle/Application/1950D74B-DAE2-43A7-8ACE-EC2021668793/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/inspect.py", line 1061, in stack
return getouterframes(sys._getframe(1), context)
File "/var/containers/Bundle/Application/1950D74B-DAE2-43A7-8ACE-EC2021668793/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/inspect.py", line 1039, in getouterframes
framelist.append((frame,) + getframeinfo(frame, context))
File "/var/containers/Bundle/Application/1950D74B-DAE2-43A7-8ACE-EC2021668793/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/inspect.py", line 1014, in getframeinfo
lines, lnum = findsource(frame)
File "/var/containers/Bundle/Application/1950D74B-DAE2-43A7-8ACE-EC2021668793/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/inspect.py", line 533, in findsource
module = getmodule(object, file)
File "/var/containers/Bundle/Application/1950D74B-DAE2-43A7-8ACE-EC2021668793/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/inspect.py", line 498, in getmodule
f = getabsfile(module)
File "/var/containers/Bundle/Application/1950D74B-DAE2-43A7-8ACE-EC2021668793/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/inspect.py", line 467, in getabsfile
_filename = getsourcefile(object) or getfile(object)
File "/var/containers/Bundle/Application/1950D74B-DAE2-43A7-8ACE-EC2021668793/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/inspect.py", line 452, in getsourcefile
if os.path.exists(filename):
File "/var/containers/Bundle/Application/1950D74B-DAE2-43A7-8ACE-EC2021668793/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/genericpath.py", line 28, in exists
os.stat(path)
TypeError: coercing to Unicode: need string or buffer, OmniClass found -
I restarted Pythonista and the errors above disappeared. The only warning message I get now is something about the Date object and the assumption of DST and the need to install or fix tzlocal though that was installed as per @ccc suggestion.
-
This was caused by a bug in
pip
when it registers installed package, which is backed byRawConfigParser
. The RawConfigParser has its own string interpolation rule which relies on the percentage sign.The bug has now been fixed and you can get it by
selfupdate -f
.