Open tomerdo opened 4 years ago
My guess is that something went wrong during the installation of webppl-viz
. The install generates a lot of output, and I suspect there will have been an error in there somewhere.
In my experience webppl-viz
is tricky to install. Here's a recipe that works for me at present. I'm using nvm
to install Node, and already have Cairo installed as mentioned in the webppl-viz
readme.
nvm install 9.0.0
npm -v #5.5.1
npm update -g npm
npm -v #5.10.0
npm explore npm -g -- npm install node-gyp@latest
mkdir ~/.webppl
cd ~/.webppl
npm install probmods/webppl-viz
Node v9 is rather old of course, but I expect it to be OK with WebPPL. It may also be possible to upgrade Node once webppl-viz
is installed.
Hope that helps.
This seems not to work for me unfortunately. It's very hard to install, but if you somehow manage, it still gives a runtime error
viktor@yggy:~/Dropbox/Work/phywppl/webppl-viz$ webppl test/render-file.wppl --require .
/home/viktor/Dropbox/Work/phywppl/webppl-viz/node_modules/vega-scenegraph/src/util/bound.js:18
return g2D || (g2D = canvas.instance(1,1).getContext('2d'));
^
TypeError: Cannot read properties of null (reading 'getContext')
at context (/home/viktor/Dropbox/Work/phywppl/webppl-viz/node_modules/vega-scenegraph/src/util/bound.js:18:44)
at textMark (/home/viktor/Dropbox/Work/phywppl/webppl-viz/node_modules/vega-scenegraph/src/util/bound.js:169:11)
at Object.itemBounds [as item] (/home/viktor/Dropbox/Work/phywppl/webppl-viz/node_modules/vega-scenegraph/src/util/bound.js:259:3)
at /home/viktor/Dropbox/Work/phywppl/webppl-viz/node_modules/vega/src/scene/Bounder.js:36:13
at Array.forEach (<anonymous>)
at Bounder.proto.evaluate (/home/viktor/Dropbox/Work/phywppl/webppl-viz/node_modules/vega/src/scene/Bounder.js:35:15)
at Model.prototype.evaluate (/home/viktor/Dropbox/Work/phywppl/webppl-viz/node_modules/vega-dataflow/src/Graph.js:329:16)
at Builder.proto.evaluate (/home/viktor/Dropbox/Work/phywppl/webppl-viz/node_modules/vega/src/scene/Builder.js:227:26)
at Model.prototype.evaluate (/home/viktor/Dropbox/Work/phywppl/webppl-viz/node_modules/vega-dataflow/src/Graph.js:329:16)
at Model.prototype.propagate (/home/viktor/Dropbox/Work/phywppl/webppl-viz/node_modules/vega-dataflow/src/Graph.js:161:22)
I've managed to get it to work using a extended set of @null-a 's instructions
#install canvas dependencies
sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
nvm install 10.24.1 #@latest annotation requires NPM version >6.?.?
npm explore npm -g -- npm install node-gyp@latest
mkdir ~/.webppl
cd ~/.webppl
npm install canvas@1.6.4
npm install probmods/webppl-viz #I had to replace this with the .tar.gz file as installation hanged when using the npm/git link.
you can grab a tar.gz just by downloading the repo and then calling npm pack
on it
Hi, I am trying to use webppl-viz, but it seems like that something wrong with canvas dependency. I get the error: "Error: Cannot find module 'canvas'".
i use the viz as
viz(thetaPosterior);
and run the program aswebppl .\survey\survey-with-half.wppl --require webppl-viz
Regards, Tomer