just adding nyaplot gem (not even calling) gives me an error on osx (yosemite, 10.10.5)
tansaku opened this issue · 14 comments
$ ruby lib/correlation.rb
/Users/tansaku/.rvm/gems/ruby-2.2.3/gems/iruby-0.2.7/lib/iruby/utils.rb:8:in `display': undefined method `session' for nil:NilClass (NoMethodError)
from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot/core.rb:45:in `init_iruby'
from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot/core.rb:48:in `<module:Nyaplot>'
from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot/core.rb:3:in `<top (required)>'
from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot.rb:4:in `require_relative'
from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/nyaplot-0.1.6/lib/nyaplot.rb:4:in `<top (required)>'
from /Users/tansaku/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from /Users/tansaku/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /Users/tansaku/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/daru-0.1.1/lib/daru.rb:45:in `block in create_has_library'
from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/daru-0.1.1/lib/daru/plotting/vector.rb:39:in `<top (required)>'
from /Users/tansaku/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/tansaku/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/daru-0.1.1/lib/daru/vector.rb:5:in `<top (required)>'
from /Users/tansaku/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/tansaku/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/daru-0.1.1/lib/daru.rb:70:in `<top (required)>'
from /Users/tansaku/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/tansaku/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/statsample-2.0.1/lib/statsample.rb:25:in `<top (required)>'
from /Users/tansaku/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from /Users/tansaku/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /Users/tansaku/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from lib/correlation.rb:2:in `<main>'
first two lines of the file:
``ruby
require 'iruby'
require 'statsample'
if I remove the nyaplot gem everything runs fine :-(
It seems that dependency of iruby , ex: rczmq or iruby itself caused your problem.
Can you try the code below?
txt = "alert(\"Hello, world!\");"
IRuby.display(IRuby.javascript(txt))
@domitry thanks - same error
2.2.3 :001 > txt = "alert(\"Hello, world!\");"
=> "alert(\"Hello, world!\");"
2.2.3 :002 > IRuby.display(IRuby.javascript(txt))
NoMethodError: undefined method `session' for nil:NilClass
from /Users/tansaku/.rvm/gems/ruby-2.2.3/gems/iruby-0.2.7/lib/iruby/utils.rb:8:in `display'
from (irb):2
from /Users/tansaku/.rvm/rubies/ruby-2.2.3/bin/irb:15:in `<main>'
is there a display variable or something I need to set?
Oops, I just noticed that you execute the script on the shell, not browser.
There are two solutions:
- Remove the line
require 'iruby'
. - run
iruby notebook
and edit the code on your browser.
or
- Remove the line
require 'iruby'
. - Run
ruby script.rb
.
Please re-open this if my suggestion not work :)
thanks @domitry
iruby notebook
fails for me like this (assuming I'm actually trying to make a graph ds.plot type: :histogram
):
→ iruby notebook
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 11, in <module>
sys.exit(start_ipython())
File "/Library/Python/2.7/site-packages/IPython/__init__.py", line 118, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/Library/Python/2.7/site-packages/traitlets/config/application.py", line 591, in launch_instance
app.initialize(argv)
File "<decorator-gen-111>", line 2, in initialize
File "/Library/Python/2.7/site-packages/traitlets/config/application.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "/Library/Python/2.7/site-packages/IPython/terminal/ipapp.py", line 305, in initialize
super(TerminalIPythonApp, self).initialize(argv)
File "<decorator-gen-7>", line 2, in initialize
File "/Library/Python/2.7/site-packages/traitlets/config/application.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "/Library/Python/2.7/site-packages/IPython/core/application.py", line 386, in initialize
self.parse_command_line(argv)
File "/Library/Python/2.7/site-packages/IPython/terminal/ipapp.py", line 300, in parse_command_line
return super(TerminalIPythonApp, self).parse_command_line(argv)
File "<decorator-gen-4>", line 2, in parse_command_line
File "/Library/Python/2.7/site-packages/traitlets/config/application.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "/Library/Python/2.7/site-packages/traitlets/config/application.py", line 487, in parse_command_line
return self.initialize_subcommand(subc, subargv)
File "<decorator-gen-3>", line 2, in initialize_subcommand
File "/Library/Python/2.7/site-packages/traitlets/config/application.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "/Library/Python/2.7/site-packages/traitlets/config/application.py", line 418, in initialize_subcommand
subapp = import_item(subapp)
File "/Library/Python/2.7/site-packages/ipython_genutils/importstring.py", line 31, in import_item
module = __import__(package, fromlist=[obj])
ImportError: No module named notebook.notebookapp
but the nyaplot gem by itself won't blow up with the iruby require removed.
I guess my basic iruby (ipython?) installation is not working? I guess I may just have to bang my head against that for a while :-/ Any tips?
If I remove require 'iruby'
I get uninitialized constant Nyaplot::Frame::IRuby
I will also try https://github.com/dilcom/gnuplotrb as @v0dro suggests ...
Yes, maybe you failed to install IPython. Can you try to run ipython notebook
?
Using plot.export_html("foo.html")
instead of plot.show
will solve uninitialized constant Nyaplot::Frame::IRuby
issue.
Plot#show works only on IRuby notebook.
Example: https://github.com/domitry/nyaplot/blob/v2/examples/rb/basic.rb
@domitry I could not - got the same error. Trying to do pip install notebook
I get permissions error. In frustration I just sudo'd it, so now both ipython notebook
and iruby notebook
work, bringing up notebooks in the browser. I tried running my script from the command line:
ruby lib/correlation.rb
but I still get the same error as before if the iruby and nyaplot gems are required - whether or not I try and draw anything.
I can view my script in the iruby notebook view through the browser, but cannot immediately see how to run it there ...
Run iruby notebook
and click New
-> Ruby *.*.*
then new window will open on your browser.
Then copy lines in correlation.rb
and paste them to boxes on the notebook just like the movie:
https://www.youtube.com/watch?v=ZxjqsIluM88
thanks @domitry - right - I have the running - really appreciate your help. Only difficulty now, is that in the notebook everything is running relative to the location of the iruby gem, rather than my project folder, which I was requiring some other classes relatively, and loading files from:
/Users/tansaku/.rvm/gems/ruby-2.2.3/gems/iruby-0.2.7/lib/iruby/
Do I need to hard code all my paths relative to root, or is there a way to make the iruby notebook run from a particular point on the file system? My googles and github issue searches "iruby require_relative" are drawing blanks ATM.
in the meantime I hardcoded all the paths relative to root, but then I get:
LoadError: cannot load such file -- nyaplot
works fine if I remove the require 'nyaplot'
Maybe require_relative
works relative to the directory where you ran iruby notebook
.
If require 'nyaplot'
fails, something I don't know is going in your PC.
thanks so much for your ongoing help on this @domitry. I would expect require_relative
to work relative to the directory where I run iruby notebook
but it seems like it is running relative to the gem.
I'm on OSX rather than PC, but so I followed your earlier advice, and I have https://github.com/domitry/nyaplot/blob/v2/examples/rb/basic.rb working generating graphs that I can view in html files.
It seems like require nyaplot
is now working (I did restart the computer as well and that might have helped). So now my correlation script runs and attempts to draw the graph, but the graph is blank and I get:
Javascript error adding output!
Error: Mismatched anonymous define() module: [object Object] http://requirejs.org/docs/errors.html#mismatch
See your browser Javascript console for more details.
and looking in the javascript console I get:
Failed to load resource: the server responded with a status of 404 (Not Found)
main.min.js:30434 ipywidgets package not installed. Widgets are not available.
main.min.js:23181 Session: kernel_created (32eb103a-2a19-4ded-a23d-c6e2990d82e2)
main.min.js:22502 Starting WebSockets: ws://localhost:8888/api/kernels/0bb0eacb-ef01-4513-b0ce-84573887c498
main.min.js:22160 Kernel: kernel_connected (0bb0eacb-ef01-4513-b0ce-84573887c498)
main.min.js:22160 Kernel: kernel_ready (0bb0eacb-ef01-4513-b0ce-84573887c498)
(program):12 finished loading d3
(program):12 finished loading downloadable
(program):25 Finished loading Nyaplotjs
main.min.js:20056 Error: Mismatched anonymous define() module: [object Object](…)
so maybe I need ipywidgets ... or maybe the basic script operation I'm following needs changing. I'm following the tutorial here:
http://v0dro.github.io/blog/2014/11/25/data-analysis-in-ruby-basic-data-manipulation-and-plotting/
In particular I'm trying to print out something thats a DaruFrame
I've installed ipywidgets, and now the error in the js console is just:
Uncaught Error: Mismatched anonymous define() module: [object Object]
http://requirejs.org/docs/errors.html#mismatch
but I think I see how I can use nyaplot to generate the html graphs for me - just wanted to add all the above to record the process I was going through. Please don't feel you need to offer any more help, unless you feel like there is something important I have missed in my exploration :-)