iPython bokeh import error Row and SizingMode - ipython

I followed this notebook to try bokeh with iPyhton Notebook: https://github.com/bokeh/bokeh/blob/0.12.3/examples/howto/notebook_comms/Basic%20Usage.ipynb
I dont know how to interpret and fix those errors:
error 1:
from bokeh.io import push_notebook, show, output_notebook
from bokeh.layouts import row
from bokeh.plotting import figure
output_notebook()
ImportError Traceback (most recent call
last) in ()
3
4 from bokeh.io import push_notebook, show, output_notebook
----> 5 from bokeh.layouts import row
6 from bokeh.plotting import figure
7 output_notebook()
/opt/conda/lib/python2.7/site-packages/bokeh/layouts.py in ()
8 from future import absolute_import
9
---> 10 from .core.enums import Location, SizingMode
11 from .models.tools import ToolbarBox
12 from .models.plots import Plot
ImportError: cannot import name SizingMode
error 2:
from ipywidgets import interact
import numpy as np
from bokeh.io import push_notebook, show, output_notebook
from bokeh.plotting import figure
output_notebook()
ImportError Traceback (most recent call
last) in ()
6
7 from bokeh.io import push_notebook, show, output_notebook
----> 8 from bokeh.plotting import figure
9 output_notebook()
/opt/conda/lib/python2.7/site-packages/bokeh/plotting/init.py in
()
3
4 from ..models import ColumnDataSource; ColumnDataSource
----> 5 from ..models.layouts import Row, Column; Row, Column
6
7 from ..io import curdoc; curdoc
ImportError: cannot import name Row
bokeh : 0.12.3
tornado: 4.4.2
python: 2.7

the problem was that the iPython notebook kernel was out of sync. restarting the notebook server was the solution

Related

ImportError with "scenarios.py"

Thank you for your help in advance!
I had the following error, for example, when running the first cell in pose.ipynb. I have tried reinstalling drake and manipulation on my local machine with the newest version, but I still have the same problem. Can you please help me out with it?
ImportError Traceback (most recent call last)
Cell In [1], line 23
9 from pydrake.all import (AbstractValue, AddMultibodyPlantSceneGraph, AngleAxis,
10 BaseField, ConstantValueSource, CsdpSolver,
11 DepthImageToPointCloud, DiagramBuilder,
(...)
19 RollPitchYaw, RotationMatrix, Simulator, StartMeshcat,
20 ge)
22 from manipulation import running_as_notebook
---> 23 from manipulation.scenarios import (AddIiwaDifferentialIK, AddMultibodyTriad,
24 AddRgbdSensor, MakeManipulationStation)
25 from manipulation.meshcat_utils import AddMeshcatTriad, draw_open3d_point_cloud
26 from manipulation.utils import AddPackagePaths, FindResource
File ~/manipulation-master/manipulation/scenarios.py:10
7 import warnings
9 import numpy as np
---> 10 from pydrake.all import (
11 AbstractValue, Adder, AddMultibodyPlantSceneGraph, BallRpyJoint, BaseField,
12 Box, CameraInfo, ClippingRange, CoulombFriction, Cylinder, Demultiplexer,
13 DepthImageToPointCloud, DepthRange, DepthRenderCamera, DiagramBuilder,
14 FindResourceOrThrow, GeometryInstance, InverseDynamicsController,
15 LeafSystem, LoadModelDirectives, LoadModelDirectivesFromString,
16 MakeMultibodyStateToWsgStateSystem, MakePhongIllustrationProperties,
...
23 DifferentialInverseKinematicsIntegrator,
24 DifferentialInverseKinematicsParameters)
26 from manipulation.utils import AddPackagePaths, FindResource
ImportError: cannot import name 'LoadModelDirectivesFromString' from 'pydrake.all' (/home/obito/env_drake/lib/python3.8/site-packages/pydrake/all.py)
LoadModelDirectivesFromString was added to Drake only in the last few days. You just need to update your installation of Drake.

ModuleNotFoundError: No module named 'pyspark.dbutils'

I am running pyspark from an Azure Machine Learning notebook. I am trying to move a file using the dbutil module.
from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()
def get_dbutils(spark):
try:
from pyspark.dbutils import DBUtils
dbutils = DBUtils(spark)
except ImportError:
import IPython
dbutils = IPython.get_ipython().user_ns["dbutils"]
return dbutils
dbutils = get_dbutils(spark)
dbutils.fs.cp("file:source", "dbfs:destination")
I got this error:
ModuleNotFoundError: No module named 'pyspark.dbutils'
Is there a workaround for this?
Here is the error in another Azure Machine Learning notebook:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-183f003402ff> in get_dbutils(spark)
4 try:
----> 5 from pyspark.dbutils import DBUtils
6 dbutils = DBUtils(spark)
ModuleNotFoundError: No module named 'pyspark.dbutils'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-1-183f003402ff> in <module>
10 return dbutils
11
---> 12 dbutils = get_dbutils(spark)
<ipython-input-1-183f003402ff> in get_dbutils(spark)
7 except ImportError:
8 import IPython
----> 9 dbutils = IPython.get_ipython().user_ns["dbutils"]
10 return dbutils
11
KeyError: 'dbutils'

error trying to import some spatial analysis libraries in jupyter notebook: ImportError: DLL load failed: El sistema operativo no puede ejecutar %1

I'm trying to run this code on jupyter notebook to work with geopandas for making geospatial analysis:
%matplotlib inline
import numpy as np, matplotlib.pyplot as plt, pandas as pd, geopandas as gpd
from mpl_toolkits.basemap import Basemap
from shapely.geometry import Point
from geopy.distance import great_circle
this is the error message I got after run the code:
ImportError Traceback (most recent call last)
<ipython-input-2-987457051b80> in <module>
1 # import necessary modules
----> 2 import numpy as np, matplotlib.pyplot as plt, pandas as pd, geopandas as gpd
3 from mpl_toolkits.basemap import Basemap
4 from shapely.geometry import Point
5 from geopy.distance import great_circle
C:\Anaconda\lib\site-packages\geopandas\__init__.py in <module>
2 from geopandas.geodataframe import GeoDataFrame
3
----> 4 from geopandas.io.file import read_file
5 from geopandas.io.sql import read_postgis
6 from geopandas.tools import sjoin
C:\Anaconda\lib\site-packages\geopandas\io\file.py in <module>
1 import os
2
----> 3 import fiona
4 import numpy as np
5 import six
C:\Anaconda\lib\site-packages\fiona\__init__.py in <module>
81 os.environ["PATH"] = os.environ["PATH"] + ";" + libdir
82
---> 83 from fiona.collection import BytesCollection, Collection
84 from fiona.drvsupport import supported_drivers
85 from fiona.env import ensure_env_with_credentials, Env
C:\Anaconda\lib\site-packages\fiona\collection.py in <module>
7
8 from fiona import compat, vfs
----> 9 from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
10 from fiona.ogrext import Session, WritingSession
11 from fiona.ogrext import buffer_to_virtual_file, remove_virtual_file, GEOMETRY_TYPES
ImportError: DLL load failed: El sistema operativo no puede ejecutar %1.
Can you provide any help?

iPython TypeError: 'int' object is not callable

Python 2.7.10 / Anaconda / windows 8.1
I have strange issue, the following code works on one solution file in the same working directory.
But when I copy call the exact same code to my sheet. I get this error, so I have no idea to fix this.
Here's the code:
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
x = np.zeros(20)
x[:5] = 10
x[5:15] = np.arange(12,31,2)
x[15:] = 30
plt.plot(x)
plt.plot([4,4],[8,32],'k--')
plt.plot([14,14],[8,32],'k--')
plt.ylim(8,32)
Traceback (most recent call last)<ipython-input-65-6b573104eb1d> in <module>()
6 plt.plot([4,4],[8,32],'k--')
7 plt.plot([14,14],[8,32],'k--')
----> 8 plt.ylim(8,32)
TypeError: 'int' object is not callable

Bokeh's hovertool inipython refuses to display tooltips

I literally copy and pasted the example of how to use the hover tool from bokeh's documentation and I still can't get this damn thing to work. I just want bokeh's hover tool to display the x and y coordinates. I think I've implemented it correctly but let me know if anything's wrong. (The ASCII file reads in flawlessly and the graph plots correctly and all the other tools work)
from bokeh.plotting import *
from bokeh.objects import HoverTool
from collections import OrderedDict
output_notebook()
%matplotlib inline
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import mpld3
from mpld3 import plugins, utils
mpld3.enable_notebook()
from pylab import *
import pandas as pd
chip1 = pd.io.parsers.read_table("Chip1_Buffer_ASCII", sep=";")
chip2 = pd.io.parsers.read_table("Chip2_Buffer_ASCII", sep=";")
chip3 = pd.io.parsers.read_table("Chip3_Buffer_ASCII", sep=";")
chip1_1=chip1
chip1_2=chip2
chip1_3=chip3
chip1_1["Frequency (Hz)"]=chip1["Frequency (Hz)"].map(lambda x: math.log10(x))
chip1_2["Frequency (Hz)"]=chip2["Frequency (Hz)"].map(lambda x: math.log10(x))
chip1_3["Frequency (Hz)"]=chip3["Frequency (Hz)"].map(lambda x: math.log10(x))
diff_1_2 = chip1 - chip2
diff_1_2["Frequency (Hz)"] = chip1_1["Frequency (Hz)"]
source1 = ColumnDataSource(chip1_1.to_dict("list"))
source2 = ColumnDataSource(chip1_2.to_dict("list"))
source3 = ColumnDataSource(chip1_3.to_dict("list"))
source4=ColumnDataSource(diff_1_2.to_dict("list"))
import bokeh.plotting as bk
bk.figure(plot_width=600, # in units of px
plot_height=600,
title="Hello World!",
tools="pan,wheel_zoom,box_zoom,select,reset,hover")
bk.hold()
bk.line("Frequency (Hz)", "-Phase (°)",line_width=2,source=source1,logx=True,color="red",xlim=[0, 10000])
bk.line("Frequency (Hz)", "-Phase (°)",line_width=2,source=source2,logx=True,color="green",xlim=[0, 10000])
bk.line("Frequency (Hz)", "-Phase (°)",line_width=2,source=source3,logx=True,color="orange",xlim=[0, 10000])
bk.line("Frequency (Hz)", "-Phase (°)",line_width=2,source=source4,logx=True,color="orange",xlim=[0, 10000])
hover = bk.curplot().select(dict(type=HoverTool))
hover.tooltips=OrderedDict([
("(x,y)", "($x, $y)"),
("index", "$index")
])
bk.show()