python-shell | Run Python scripts from Node.js with simple ( but efficient | Runtime Evironment library
kandi X-RAY | python-shell Summary
kandi X-RAY | python-shell Summary
A simple way to run Python scripts from Node.js with basic but efficient inter-process communication and better error handling.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of python-shell
python-shell Key Features
python-shell Examples and Code Snippets
Community Discussions
Trending Discussions on python-shell
QUESTION
I am trying to connect oracle database from AWS glue using cx_oracle but i am getting this error message
DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory". See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help
I tried to downoad the so files as per the document and stored it in S3 which has been linked to Glue with --extra-files parameter but still getting same error message
I have tried this stackoverflow question and also tried to set rpath with s3 url but no success. Any idea would really help
...ANSWER
Answered 2022-Feb-12 at 20:09This answer is a compilation of this and this and a lot of discussion around the former in the comments. Credit for the rpath
patching solution goes to @harjeet-singh, the original author of the abovementioned answer and for the libaio
to @good-will, but there are still some steps around these solutions that keep confusing people, so that is why I am going to consolidate everything in a single step-by-step answer here.
In order to connect to an Oracle database using cx-Oracle
from a Python shell AWS Glue job, we need to bundle the oracle client libraries with it. Furthermore, the libraries have to be patched with a correct rpath
in order to load correctly, because in Glue runtime we have filesystem write access only to /tmp
, which is where our archive will be, but cx-Oracle
can't know that and expects a different directory by default. And the LD_LIBRARY_PATH
hack cannot be implemented because we have no control over how the Glue job is launched.
- Download Instant Client Basic ZIP package for x86-64 Linux from here. This guide uses version 21.5.0.0.0
QUESTION
I am trying to pass python json results to html ajax from node js.
What I want to make is, take some inputs from the client side, and when a submit button is hit, ajax is sending the variables to Node JS then the /data middleware runs a python script which handles the DB and stores the variables and showing the results.
What I did so far is, I can take inputs from the client side, and send the variables from html to Node JS using ajax, and I can also run the python script and it stores the variables to my DB. I can see the results from the back end side. But I do not know how to send back the results to the ajax client side.
Below is my part of back end side Node JS code.
...ANSWER
Answered 2022-Feb-04 at 08:06try changing arguments in python results callback:
QUESTION
I wrote a rather complex algorithm in Python that uses some special libraries that only Python has. Now I am trying to write a server in node js that can get Api requests that run my algorithm. So I copied the project of the algorithm (which runs fine via Pycharm) to the node's project folder and now it returns an error that it does not recognize the imports that I have in Python's project. I'm trying to use the python-shell modules.
this is TestScript.py:
...ANSWER
Answered 2022-Jan-30 at 10:23needed to remove all the 'algorithm.Version3.' from the imports in the python code. for example:
QUESTION
Would anyone know when using python-shell if you can keep the python script running when its called from Javascript? Maybe call a method from a Python class from Javascript using python-shell?
For example this code works but it kills the Python script every time its called.
...ANSWER
Answered 2021-Dec-29 at 07:58.js
QUESTION
I am trying to learn how to exchange data between Node and Python with python-shell
, on the git repo they have some example code:
Borrowing some of this code, this is app.js
:
ANSWER
Answered 2021-Dec-28 at 15:42Replace import {PythonShell} from 'python-shell';
with let {PythonShell} = require('python-shell');
Edit: In .py file, import sys
and then the arguments passed from nodejs will be available in sys.argv
as array. I suppose by putting if checks you can call specific functions and at the end whatever you print in python would be available in results
in js
Sample:
.py file:
QUESTION
I am experimenting with a node red - VOLTTRON (Python framework) integration where I am hoping to view the VOLTTRON message bus in Node Red.
When I do the appropriate steps as defined in the README like copying the files over to the correct ~/.node-red/nodes/volttron
and getting the correct VOLTTRON authentication keys
When I start Node Red, I get an error:
...ANSWER
Answered 2021-Dec-12 at 23:04In the previous answer I had to guess which version of python-shell
was used by the node as it has no hints, so I picked the current latest version (3.0.1) as an arbitrary choice.
It appears that this was the wrong choice soI suggest you edit the package.json
file again and change the ^3.0.1
version for the python-shell
dependency and change it to ^1.0.4
QUESTION
I am trying to learn how to pass data back and forth between node and Python using stdin and stdout.
This is something super bare bones where the node app.js
calls the Python file test.py
.
ANSWER
Answered 2021-Oct-28 at 17:55Here is an answer to a slightly simpler question - we'll see if that is helpful. It leaves a python process running, and sends messages and receives messages back from a python script. Feel free to down-vote this if I am way off:
app.js:
QUESTION
I am having a strange error on my MacBook Air (M1, 2020) where python3.8 is being installed as a 64 bit binary from homebrew brew install python@3.8
and yet, is being run in 32 bit mode, thus causing errors when trying to download packages.
Here is what I have tried:
- Reinstalling and confirming that the executable is running in 32 bit
ANSWER
Answered 2021-Oct-25 at 23:08Turns out I had an error in my command:
python3.8 -c 'import sys;print("%x" % sys.maxsize, sys.maxsize > 2**64)'
should be:
python3.8 -c 'import sys;print("%x" % sys.maxsize, sys.maxsize > 2**32)'
Which returns true when you're running python in 64 bit mode.
This specific problem is likely something else, and as such I am closing this question.
QUESTION
In my glue script (Spark 3.1, Python 3, Glue 3) I'm trying to use df.to_excel()
function from pandas library. Apparently pandas library has dependencies on openpyxl
. My code is:
ANSWER
Answered 2021-Sep-12 at 17:37In the newer versions of glue can you skip the egg/wheel approach and install at runtime. In the Job Parameters put a key "--additional-python-modules" and in the value put "openpyxl, pandas".
QUESTION
Recently, I'm trying to configure emacs as my python IDE and I use anaconda in my computor. I have use conda package and python-mode in emacs in the init.el as following:
...ANSWER
Answered 2021-Sep-01 at 11:26The proper way to use python-shell-send-buffer
is to run it from a buffer of Python code; Emacs will then send the contents of that buffer to the Python REPL you started with run-python
.
Don't run this command in the run-python
buffer (*Python*
) itself; it doesn't make any sense to submit that buffer's contents to Python as code.
To quickly demonstrate how this works,
Create a buffer
demo.py
and type some Python code into it.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install python-shell
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page