I can not execute pptk.viewer() on google colab - point-cloud-library

I can not visualize point clouds with pptk on google colab. It stays running permanently and I have to stop it manually.
It does work with Jupyter, but I wanted to use it on colab.
What I'm doing is just this:
import numpy as np
import pptk
x = np.random.rand(100, 3)
v = pptk.viewer(x)
v.set(point_size=0.0001)
I am also installing pptk with:
!pip install pptk
Does anybody knows why isn't it working?
Thank you!

Related

Shift Tab for showing the documentation of a command in Jupyter Notebook is not working

I have a problem in using the shortcut 'shift tab' in order to get more informations of the package or command I am typing in in a cell. I installed Jupyter notebook via anaconda very recently, I am using python 3.7 and Ubuntu 18.04.
Do you know how to fix this problem ? I googled a lot but could not find a solution.
Many thanks.
Let's say you wrote the below code and trying to get the signature/documentation of function read_csv() with Shift+Tab (It may not work some times)
Code:
import pandas as pd
pd.read_csv()
-> First type only below code
pd.read_csv? ## Execute this code with Shift+Enter
-> Now when you type pd.read_csv and type Shift+Tab, this will show u signature/documentation... This is just a workaround...
Follow two steps:
Step 1: Run that cell first (shift + enter)
Step 2: After running the cell, press the shift + tab.
It worked for me. I hope it will work for you too :)
In the Google Colab environment, if fixed it as follows:
Tools | Settings | Editor |uncheck Automatically trigger code inspection.
Then, Tab and Shift-Tab worked as expected.
I also faced a similar problem but can you confirm that you imported the library in the jupyter notebook and then were calling one of the methods of the library?
What I observed is that if the library wasn't imported into the notebook then the documentation wasn't also showing using Shift+Tab. Once I imported it, then the shortcut was working to show the documentation.
Scenario 1:
import numpy as np #Pressed Enter for next line
a=np.random.randint #Shift + Tab not working
Scenario 2:
import numpy as np #Shift + Enter
a=np.random.randint #Shift + Tab working
Just Run the tab of your code
Then bring your curser in the parenthesis and press shift + tab
press shift + tab + tab for more info
On Google colab:
clicking on the function after running,
move the cursor away and then
bring the mouse and hover it over causes it to pop up.
Note: colab Tools | Settings | Editor | check Automatically trigger code inspection (first setting)
Run again your line of importing the libraries. Now, having loaded your modules you should be able to see the command documentation.

How do I get HoloViews to display in Google Colabs notebooks?

I can't get any HoloViews graphics to display in any Google Colabs notebook.
For example even the simple Bokeh example right out fo the HoloViews introduction
points = hv.Points(np.random.randn(500,2))
points.hist(num_bins=51, dimension=['x','y'])
fails to show anything, without any error being reported, while the same code (and all example code from HoloViews) works fine in local Jupyter notebooks.
If I download the Colabs notebook locally and open it, I see the following where I say nothing for output in Colabs:
No (safe) renderer could be found for output. It has the following MIME types: application/javascript, application/vnd.bokehjs_load.v0+json
How do I get Bokeh HoloViews to display in Google Colabs notebooks?
See https://github.com/pyviz/holoviews/issues/3551 . Colaboratory has some serious limitations on how it handles notebooks, and for now you have to do this once:
import os, holoviews as hv
os.environ['HV_DOC_HTML'] = 'true'
Then for every single cell with a plot in it you have to re-load the JS:
hv.extension('bokeh')
hv.Curve([1, 2, 3])
It would be great if Google could fix that, as it's unworkable in my opinion.

loading bokehJS in jupyter lab

I am having a strange behavior with bokeh library.
So apparently, I am trying to create some beautiful plots with bokeh. When I try to load the bokeh in JupyterLab, I get constant, "Loading bokehJS..." message but if I try to plot with jupyter (from bokeh.io import output_notebook, show output_notebook()), I could plot it. It looks like lab has some issues? or am I not using lab properly?
comparative screenshot attached. Dark (JupyterLab), Light(Jupyter Notebook)
You likely need to install the jupyterlab_bokeh extension:
https://docs.bokeh.org/en/latest/docs/user_guide/notebook.html#jupyterlab

bokeh not showing in jupyter notebook

I am unable to plot even the most basic of Bokeh plots in Jupyter Notebook. I had a search and can see that this was a reported problem a little over a year ago but nothing since - is it still an issue for others?
from bokeh.io import output_notebook, show
from bokeh.plotting import figure
output_notebook()
p = figure(plot_width=400, plot_height=400)
p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=15, line_color="navy",
fill_color="orange", fill_alpha=0.5)
show(p)
I get the "BokehJS 0.12.10 successfully loaded." message, but not plot. Note that it outputs html files ok.
I've tried changing the environment variables using:
import os
os.environ['BOKEH_RESOURCES'] = 'inline'
But this has not effect either. It's bee a frustrating afternoon so any help would be appreciated!
Running the lines below worked for me
from bokeh.resources import INLINE
import bokeh.io
from bokeh import *
bokeh.io.output_notebook(INLINE)
My guess is that your version of the notebook is too old. There is no technical path to simultaneously supporting both the new JupyterLab and classic notebook versions older than 5.0, at all. Supporting JupyterLab is an imperative, so as of recently, Bokeh can only support classic notebook 5.0 and newer. So, you can:
downgrade Bokeh (<= 10.12.8), or
updgrade Jupyter Notebook (>= 5.0), or
switch to recent JupyterLab betas. You will need to install the Jupyter extension with
jupyter labextension install jupyterlab_bokeh

Is it possible to use nbconvert to export a Bokeh plot to a single html file?

I tried to use nbconvert > HTML and it returns random bokeh logos
here is my code:
import pandas as pd
from bokeh.plotting import *
output_notebook()
df = pd.DataFrame({'rev':[234,345,657,7]})
df
line(df['rev'],df['rev'], color="red", line_width=2,
title="Archimean", legend="Archimedean")
show()
A small CSS bug made it into 0.5.0 that affects nbconvert output. There is alread a fix checked into master. We will be releasing 0.5.1 early next week.

Resources