Questions tagged [pyv8]

Python wrapper for Google's V8 JavaScript engine

PyV8 is a python wrapper for Google's V8 engine, it acts as a bridge between the Python and JavaScript objects, and supports to hosting Google's V8 engine in a Python script.

Example:

>>> import PyV8
>>> ctxt = PyV8.JSContext()          # create a context with an implicit global object
>>> ctxt.enter()                     # enter the context (also support with statement)
>>> ctxt.eval("1+2")                 # evalute the javascript expression
3                                    # return a native python int
>>> class Global(PyV8.JSClass):      # define a compatible javascript class
...   def hello(self):               # define a method
...     print "Hello World"    
...
>>> ctxt2 = PyV8.JSContext(Global()) # create another context with the global object
>>> ctxt2.enter()                    
>>> ctxt2.eval("hello()")            # call the global object from javascript
Hello World                          # the output from python script
41 questions
8
votes
2 answers

PyV8 Issue Sublime Text3

im having some problems and my new Ubuntu 12.04 64 installation. I have installed sublime text, i got both, 2/3 and both are giving this error when i try to install EMMET i have research a lot of info, also trying to install PYV8 Manually, but its…
Zilashak
  • 79
  • 1
  • 1
  • 4
4
votes
1 answer

Loading JavaScript library in Python using PyV8

I am trying to use some features of the leaflet.js library in my Python code. And in order to execute JS commands in the code I am using PyV8. But I am unable to load the leaflet.js library into PyV8 context. When I do…
aa8y
  • 3,854
  • 4
  • 37
  • 62
4
votes
1 answer

PyV8 disable automatic garbage collection

I'm having an issue which seems to be related with the way Python & PyV8's garbage collection interact. I've temporarily solved the issue by disabling python's garbage collection, and calling gc.collect and PyV8.JSEngine.collect together every few…
Claudiu
  • 224,032
  • 165
  • 485
  • 680
3
votes
1 answer

Is there a way I can evaluate a JavaScript function with default parameters using PyV8?

I am trying to call a function from JavaScript in python. I am using PyV8 and I can successfully call a function and print out the result. However, if the function contains a default parameter then I get a Syntax Error. This works fine. import…
Qwaddles
  • 72
  • 5
3
votes
2 answers

Retrieving comments (disqus) embedded in another web page with python

I'm scrapping a web site using python 3.5 (Beautifulsoup). I can read everything in the source code but I've been trying to retrieve the embedded comments from disqus with no success (which is a reference to a script). The piece of the html code…
pacode
  • 63
  • 10
3
votes
5 answers

How can I install pyv8 in Ubuntu 14.04?

I installed the libv8 and libboost-all-dev Ubuntu packages, then ran sudo pip install pyv8 And got: building '_PyV8' extension creating build/temp.linux-x86_64-2.7 creating build/temp.linux-x86_64-2.7/src x86_64-linux-gnu-gcc -pthread…
Sean W.
  • 4,944
  • 8
  • 40
  • 66
3
votes
1 answer

Converting Python objects to JavaScript for PyV8

I'm trying to pass Python data (lists, dicts, strings..., arbitrarily nested) to PyV8. class Global(object): def __init__(self, data): self.data = data ctx = PyV8.JSContext(Global([{'a':1}])) ctx.enter() res =…
jd.
  • 10,678
  • 3
  • 46
  • 55
3
votes
2 answers

Embedding Node.js in Python

I am looking at the option of embedding node.js into python to add node.js functionality to my existing python code. I know that it can be done the other way around, as described in this post. However, I want to keep the as much of the existing…
Toaster
  • 1,911
  • 2
  • 23
  • 43
2
votes
0 answers

How do I install pyv8 on Mac?

I have been trying to install pyv8 on my mac (BigSur, M1 Mac) inside a conda environemnt. After spending a whole day resolving dependencies, I got stuck at what seems like a GCC compilation failure. I have attached the log below, can someone help me…
shikhar.ja
  • 457
  • 1
  • 4
  • 11
2
votes
1 answer

Run python from javascript

I have implemented an accelerometer Reader in python and I want to execute a function in a javascript file when a new value is read that will: 1 - update the value in a database 2 - broadcast the new value to all connected client ( via Socket.io) …
Observablerxjs
  • 692
  • 6
  • 22
2
votes
0 answers

How to install PyV8 in windows10 platform by python3+?

python version is python3.6.5, and i want to install PyV8 in windows 10. i have got two files, such as PyV8.py, _PyV8.pyd. and put them into site-packages on my computer. but, there are some mistakes: >>> import PyV8 Traceback (most recent call…
xnchall
  • 21
  • 3
2
votes
1 answer

Error raised while trying to install PyV8 for Python 3.4

I tried to install PyV8 for Python 3.4, but an error was raised. I googled for solutions, but I couldn't find a way to install PyV8 for Python 3.4 on Windows. My system: Windows 10 home Python 3.4 (64bit) Eclipse Neon 2 I tried using PIP: C:\Program…
Sama
  • 55
  • 8
2
votes
1 answer

ImportError: libboost_python.so.1.41.0: cannot open shared object file: No such file or directory

I am trying to install PyV8 to debian (I tried to ubuntu too)according the steps here http://www.wikisecure.net/importing-pyv8-engine-into-python-v2-7-the-easy-way/ However I always get ImportError: libboost_python.so.1.41.0: cannot open shared…
Fr. Hrdina
  • 23
  • 1
  • 6
2
votes
0 answers

How could I get the js variables in python with PyV8 (js to python)

I want to translate the javascript to python. But when I get the bgAudio, it equals [object Object]. Anyone who can tell me how to get the value of "bgAudio".(type of json better,like {"url":"a/b/c/d/e.mp3","name":"aaa.mp3"})? Or how to get the…
Jaccorot
  • 21
  • 2
2
votes
1 answer

Command "python setup.py egg_info" failed with error code 1 when installing PyV8

I get the following error when installing PyV8 using Python 2.7.10 on Windows: Command "python setup.py egg_info" failed with error code 1 in c:\users\MyUsername\appdata\local\temp\pip-build-omxgan\pyv8 I ran pip install --upgrade setuptools with…
Alir Kahi
  • 1,264
  • 2
  • 15
  • 27
1
2 3