n-riesco / ijavascript

IJavascript is a javascript kernel for the Jupyter notebook
Other
2.18k stars 187 forks source link

(only) async example not working #68

Closed drandreaskrueger closed 7 years ago

drandreaskrueger commented 8 years ago

After some initial problems ...

(ijs only works when I open cmd.exe as administrator; in contrast when I open cmd.exe as normal user and then type 'ijs' I am getting a 'ijs' is not recognized as an internal or external command, operable program or batch file.)

... I am totally excited about this great system you have created for us.

Kudos!

I am working through the tutorial, and all is going well.
BUT the one example not.

http://n-riesco.github.io/ijavascript/doc/async.ipynb.html

function countTo(number, milliseconds) {
    var counter = function() {
        console.log(counter._n++);

        if (counter._n > number) {
            clearInterval(counter._intervalObject);
            console.warn("Done!");
        }
    };
    counter._n = 1;
    counter._intervalObject = setInterval(counter, milliseconds);
}

countTo(5, 1000);

the result is only:

undefined

without any counting to 5.

This is my system:

npm --version && node --version && ijs --version && ipython --version
3.5.2
v4.4.2
5.0.11-beta.0
4.1.2

npm install -g ijavascript
C:\Users\Andreas\AppData\Roaming\npm\ijs -> C:\Users\Andreas\AppData\Roaming\npm\node_modules\ijavascript\bin\ijavascript.js
C:\Users\Andreas\AppData\Roaming\npm
└── ijavascript@5.0.11-beta.0

npm list -g ijavascript
C:\Users\Andreas\AppData\Roaming\npm
└── (empty)
npm ERR! code 1

ipython locate
C:\Users\Andreas\.ipython    

npm ls -g
 ....
├─┬ ijavascript@5.0.11-beta.0
│ ├─┬ jmp@0.4.0
│ │ └─┬ zmq@2.14.0
│ │   ├── bindings@1.2.1
│ │   └── nan@2.0.9
│ ├── nel@0.4.0-beta.2
│ └── node-uuid@1.4.7
...

P.S.: The $$async$$ snippets are working.

n-riesco commented 8 years ago

I'm in the process of updating the way IJavascript handles asynchronous output. It looks like the beta version (ijavascript@5.0.11-beta.0) has broken that example. It should work with the previous version ijavascript@5.0.10.

IJavascript@5.0.10 handles asynchronous outputs by showing them in the last active cell.

IJavascript@5.0.11 wraps console.log to ensure the asynchronous output is shown in the cell where the asynchronous code was executed. I haven't updated the documentation yet, but I described the new API here.

n-riesco commented 8 years ago

I don't test IJavascript regularly (or very thoroughly) on Windows. I rely on reports from users like yours. If I remember correctly, when I tested IJavascript on a Windows machine, I installed it locally. Could you check whether a local install works for you (npm install ijavascript)?

n-riesco commented 8 years ago

I've fixed the issue with the above asynchronous example in nel@0.4.0-beta.3. To pick up the latest changes, you can run:

npm update ijavascript nel
drandreaskrueger commented 8 years ago

Could you check whether a local install works for you (npm install ijavascript)?

Done.

Yes, the installation itself seems to work:

> zmq@2.14.0 install D:\javascriptLearning\node_modules\zmq
> node-gyp rebuild

D:\javascriptLearning\node_modules\zmq>if not defined npm_config_node_gyp (node "C:\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild ) 
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  binding.cc
..\binding.cc(642): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(643): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(644): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(645): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(646): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(647): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(648): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(649): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(650): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(651): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(665): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(666): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(667): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(668): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(669): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(670): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(671): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(672): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(673): warning C4244: 'argument' : conversion from 'int64_t' to 'const int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(674): warning C4244: 'argument' : conversion from 'int64_t' to 'int', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
D:\javascriptlearning\node_modules\nan\nan_new.h(208): warning C4244: 'argument' : conversion from 'int64_t' to 'double', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
          ..\binding.cc(593) : see reference to function template instantiation 'v8::Local<v8::Number> Nan::New<v8::Number,T>(A0)' being compiled
          with
          [
              T=int64_t
  ,            A0=int64_t
          ]
          ..\binding.cc(647) : see reference to function template instantiation 'v8::Local<v8::Value> zmq::Socket::GetSockOpt<int64_t>(int)' being compiled
D:\javascriptlearning\node_modules\nan\nan_new.h(208): warning C4244: 'argument' : conversion from 'uint64_t' to 'double', possible loss of data [D:\javascriptLearning\node_modules\zmq\build\zmq.vcxproj]
          ..\binding.cc(593) : see reference to function template instantiation 'v8::Local<v8::Number> Nan::New<v8::Number,T>(A0)' being compiled
          with
          [
              T=uint64_t
  ,            A0=uint64_t
          ]
          ..\binding.cc(649) : see reference to function template instantiation 'v8::Local<v8::Value> zmq::Socket::GetSockOpt<uint64_t>(int)' being compiled
  win_delay_load_hook.c
     Creating library D:\javascriptLearning\node_modules\zmq\build\Release\zmq.lib and object D:\javascriptLearning\node_modules\zmq\build\Release\zmq.exp
  Generating code
  Finished generating code
  zmq.vcxproj -> D:\javascriptLearning\node_modules\zmq\build\Release\\zmq.node
D:\javascriptLearning
├── d3@3.5.16 
└─┬ ijavascript@5.0.11-beta.0 
  ├─┬ jmp@0.4.0 
  │ └─┬ zmq@2.14.0 
  │   ├── bindings@1.2.1 
  │   └── nan@2.0.9 
  ├── nel@0.4.0-beta.3 
  └── node-uuid@1.4.7 

is in log.txt when I do this:

D:\javascriptLearning\ijavascript-testing>npm install ijavascript > log.txt

which prints to console this:

npm WARN enoent ENOENT: no such file or directory, open 'D:\javascriptLearning\package.json'
npm WARN javascriptLearning No description
npm WARN javascriptLearning No repository field.
npm WARN javascriptLearning No README data
npm WARN javascriptLearning No license field.

BUT then ijs still does not work:

D:\javascriptLearning\ijavascript-testing>ijs

results in:

'ijs' is not recognized as an internal or external command,
operable program or batch file.
drandreaskrueger commented 8 years ago

Hah. Found the way (local installation with npm install ijavascript) :

D:\javascriptLearning\ijavascript-testing>..\node_modules\.bin\ijs

so I have to manually address the correct path

..\node_modules\.bin\ijs

then ijs gets executed:

[TerminalIPythonApp] WARNING | Subcommand `ipython notebook` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter notebook`... continue in 5 sec. Press Ctrl-C to quit now.
[I 05:29:27.289 NotebookApp] Serving notebooks from local directory: D:\javascriptLearning\ijavascript-testing
[I 05:29:27.289 NotebookApp] 0 active kernels
[I 05:29:27.289 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 05:29:27.290 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
drandreaskrueger commented 8 years ago

npm update ijavascript nel

Great.

Yes, fixed:

undefined

1
2
3
4
5

Done!

Very nice. Thanks a lot!

:-)

n-riesco commented 8 years ago

I'm sorry to here there is still a problem executing ijs. I will try to reproduce it in my Windows machine. Could you describe what method you used to install Node.js?

drandreaskrueger commented 8 years ago

Oh thanks. That is kind.

1) uninstalled old nodejs (v4.2...) 2) installed https://nodejs.org/dist/v4.4.2/node-v4.4.2-x64.msi 3) npm --version && node --version 3.5.2 v4.4.2