Closed mattloose closed 7 years ago
Hi.
Thanks for your interest. Sorry I don't have Macbook. So let me guess...
First of all, please download the repo as is. The code snippet in README.md
may or may not be totally correct (it should be, but...)
It seems that the problem occurs on the python part.
(Maybe because of incorrect installation of gevent
?)
run
# strongly recommend: do this inside virtualenv
# !! pay attention to this !!
pip install gevent
pip install pyzmq
pip install future # necessary in python 2
pip install msgpack-python
pip install zerorpc
# run
python ./pycalc/api.py
## start running on tcp://127.0.0.1:4242 <- this line should show up?
Open another terminal and run
zerorpc tcp://localhost:4242 calc "1 + 1"
## connecting to "tcp://localhost:4242" <- it should show up
## 2.0 <- it should show up
I believe that, if there are any errors, you should see the errors in the above two steps.
Furthermore, open python and check whether it works:
import gevent
For example, I have to run something like sudo apt-get install libevent-dev
on Ubuntu Linux.
And since you run python as it is, and open Electron, then maybe you can try to comment out the python subprocess codes and see if it is ok?
I mean line 10 ~ 61 in https://github.com/fyears/electron-python-example/blob/master/main.js.
Why? Because you don't need to start a subprocess of python from node.js in this case
There is another problem. After npm installed dependencies there is an "Uncaught Error: Module version mismatch. Expected 50, got 51." bindings.js:83
Thanks for getting back to me so quick. I also have seen the Module mismatch error...
However - all of the tests you suggest above work correctly and as expected. I see no errors. I have also commented out lines starting the python subprocess.
It looks to me that this is something more fundamental in the python node zerorpc ?
@ar7max
When you are doing npm install
, you need to specify npm_config_*
as shown in here.
Pay attention to your electron version and
# Electron's version.
export npm_config_target=1.2.3
Then
rm -rf ~/.node-gyp
rm -rf ~/.electron-gyp
rm -rf ./node_modules
And try npm install
again.
@mattloose
Very "interesting"... And I get confused... 🙁
Maybe your node.js code could not communicate with python server correctly????
How about this:
run standalone python server python pycalc/api.py
use another clean node.js environment, npm install zerorpc
, then run line 1 ~ 12 in renderer.js
in node.js cli. As you can see, the only thing it does is to call echo()
function defined in the python part.
If, step 2 goes well, also try to invoke calc()
from pure node.js environment (you know how to do it 😜). If it also goes well, then we know that some problems occur while installing node.js libraries for electron, which needs your further investigation.
@ar7max
One more thing, when you are in Windows, checkout the syntax about setting environment variables.
export npm_config_target=1.4.15 # electron version
export npm_config_arch=x64
export npm_config_target_arch=x64
export npm_config_disturl=https://atom.io/download/electron
export npm_config_runtime=electron
export npm_config_build_from_source=true
npm config ls
The above export K=V
syntax is available for Linux/OS X, and git-bash
and mingw bash, etc, on Windows. But it's NOT available on Windows cmd.exe
or PowerShell. If you are in cmd.exe
or PowerShell, use set K=V
syntax as shown here.
@fyears, I'm using Arch Linux with Python 3.6.
Not quite sure how I have fixed this, but a complete rebuild of electron and cleaning up of node seems to have worked. Thanks for the cool demo!
@ar7max By the way, may you consider removing my personal blog repo from your account? If necessary you may just fork the current dev repo instead of the blog repo. Thank you! :-)
@fyears, done.
Hi,
Thanks for this great demo!
However - when I run it (python 3.6 or python 2.7) I get the following problems:
1 - running as is I get no result from the calculation and a console error reporting "Lost remote after 10000ms"
2 - If I instead run the python code in the background (rather than from the electron app) then fire the electron app I see the following errors:
This looks to be something to do with the way strings are being passed around, but any suggestions? Running on OSX