Bokeh Error when making simple widget in Python - python

I keep getting this ImportError for just trying to set up a basic widget slider. Below is the input and error message.
import bokeh
from bokeh.io import output_notebook, show
import bokeh.models.widgets
from bokeh.models.widgets import Slider
slider = Slider(start = 0, end = 10 , value = 1, step=.1, title = 'do nothing')
show(slider)
ImportError Traceback (most recent call last)
<ipython-input-100-2c4894dccaf0> in <module>()
10 slider = Slider(start = 0, end = 10 , value = 1, step=.1, title = 'do nothing')
11
---> 12 show(slider)
11 frames
/usr/local/lib/python3.6/dist-packages/tornado/gen.py in <module>()
79 import types
80
---> 81 from tornado.concurrent import (
82 Future,
83 is_future,
ImportError: cannot import name 'future_set_exc_info'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
I do have bokeh package installed as well. Not sure what the issue is. Any help is appreciated.

In order to fix the error above, the tornado package must be up to date. To see what version works, simply look up the package itself to see what is the current version. Then input the following code at the beginning of your program to update the package.
# update tornado package
!pip install tornado==6.0.4
import tornado

Related

ModelicaRes import fails in python

I want to use ModelicaRes to open my Dymola results in python but the import fails.
from modelicares.simres import SimRes
Gives the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In [2], line 1
----> 1 from modelicares.simres import SimRes
File C:\ProgramData\Miniforge3\envs\main\lib\site-packages\modelicares\__init__.py:54
40 __version__ = '0.12.2'
43 # Standard pylint settings for this project:
44 # pylint: disable=I0011, C0302, C0325, R0903, R0904, R0912, R0913, R0914, R0915,
45 # pylint: disable=I0011, W0141, W0142
(...)
52 # These will be available directly from modelicares; others must be loaded from
53 # their submodules.
---> 54 from modelicares.simres import SimRes, SimResList
55 from modelicares.linres import LinRes, LinResList
56 from modelicares.util import (add_arrows, add_hlines, add_vlines, ArrowLine,
57 closeall, multiglob, figure, load_csv, save,
58 saveall, setup_subplots)
File C:\ProgramData\Miniforge3\envs\main\lib\site-packages\modelicares\simres.py:50
48 from itertools import cycle
49 from matplotlib import rcParams
---> 50 from matplotlib.cbook import iterable
51 from matplotlib.pyplot import figlegend
52 from pandas import DataFrame
ImportError: cannot import name 'iterable' from 'matplotlib.cbook' (C:\ProgramData\Miniforge3\envs\main\lib\site-packages\matplotlib\cbook\__init__.py)
I tried DyMat and Buildingspy but I would prefer to use ModelicaRes. Because Buildingspy makes use of DyMat which is quiet old and seems unmaintained.
I also had this issue.
I fixed this in my fork of modelicares here: https://github.com/sede-fa/ModelicaRes
I basically replaced any reference to matplotlib.cbook to numpy to get the iterable function as shown here: https://github.com/kdavies4/ModelicaRes/issues/42
You can install this via pip by doing: pip install git+https://github.com/sede-fa/ModelicaRes.git

Where is my downloaded program(thermo.chemical) located?

After installing thermo.chemical, I wanted to know how I can check,
first of all, which version is installed on my computer and second where the program is located (path).
What do I have to enter in my terminal.
I tried the following, but it does not work.
import ipywidgets as widgets
def clicked(arg):
print(thermo.__version__())
button_download = widgets.Button(description = 'Version', button_style = 'primary')
button_download.on_click(clicked)
display(button_download)
This error ist showed:
Traceback (most recent call last)
<ipython-input-51-8d76d70a85bb> in clicked(arg)
3
4 def clicked(arg):
----> 5 print(thermo.__version__)
6
7 button_download = widgets.Button(description = 'Version', button_style = 'primary')
NameError: name 'thermo' is not defined
Many modules have variable __version__ and all modules, submodules and scripts have __file__
import thermo
print(thermo.__version__)
print(thermo.__file__)
BTW:
You have to import thermo to have access to elements in thermo.
Using from thermo.chemical import Chemical you have access only to Chemical but not to thermo.

'FileDataset' object has no attribute 'DoseGrid'

I have been trying to use the dicompyler-core to put together two dose grids from two different dose dicoms.
import pydicom
import numpy as np
import os
import glob
from dicompylercore import dicomparser, dvh, dvhcalc
from dicompylercore import dose
I keep receiving this error while trying to import dose
ImportError Traceback (most recent call last)
<ipython-input-120-6605335fa321> in <module>
5 import glob
6 from dicompylercore import dicomparser, dvh, dvhcalc
----> 7 from dicompylercore import dose
ImportError: cannot import name 'dose' from 'dicompylercore'
Because of this import error, I think that is why there is no attribute to be found when I try and add the two dose grids together
dose1 = dicomparser.DicomParser("RD.CW.dcm")
dose2 = dicomparser.DicomParser("RD.CCW.dcm")
grid_1 = dose.DoseGrid()
grid_2 = dose.DoseGrid()
grid_sum = grid_1 + grid_2
grid_sum.save_dcm("grid_sum.dcm")
It gives me this error
~\Anaconda3\lib\site-packages\pydicom\dataset.py in __getattr__(self, name)
550 if tag is None: # `name` isn't a DICOM element keyword
551 # Try the base class attribute getter (fix for issue 332)
--> 552 return super(Dataset, self).__getattribute__(name)
553 tag = Tag(tag)
554 if tag not in self._dict: # DICOM DataElement not in the Dataset
AttributeError: 'FileDataset' object has no attribute 'DoseGrid'
I am new to working with dicom files and with dicompylercore. I am unsure if this is related to the dicom files I am working itself or if there is some issue with the dicomplyercore package itself. Are there any suggestions on what I could do to fix this?
The dose module has been added to dicompylercore after the last PyPi release, so you have to install the version from GitHub, if you want to use it:
pip install git+https://github.com/dicompyler/dicompyler-core
I'm not sure how stable this version is, but you can ask about the next release on the development site.

Unexpected keyword argument 'noise_model'

The following code throws an error. Based on some issues that I read on qiskit github, it seems that it has something do with run configs vs. compile configs but I could not find any other info that will help me resolve this issue.
from qiskit import QuantumCircuit, IBMQ, execute
from qiskit import BasicAer as Aer
from qiskit.providers.aer import noise
ckt = QuantumCircuit(2, 2)
ckt.h(0)
ckt.cx(0, 1)
ckt.measure(0, 0)
ckt.measure(1, 1)
qsim = Aer.get_backend("qasm_simulator")
IBMQ.load_account()
provider = IBMQ.get_provider(hub="ibm-q")
qc = provider.get_backend("ibmqx2")
props = qc.properties()
coupling_map = qc.configuration().coupling_map
noise_model = noise.device.basic_device_noise_model(props)
job = execute(
ckt,
qsim,
noise_model=noise_model,
coupling_map=coupling_map,
basis_gates=noise_model.basis_gates
)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-1-2f987d65d1f7> in <module>
25 noise_model=noise_model,
26 coupling_map=coupling_map,
---> 27 basis_gates=noise_model.basis_gates
28 )
~/.venvs/qk/lib/python3.7/site-packages/qiskit/execute.py in execute(experiments, backend, basis_gates, coupling_map, backend_properties, initial_layout, seed_transpiler, optimization_level, pass_manager, qobj_id, qobj_header, shots, memory, max_credits, seed_simulator, default_qubit_los, default_meas_los, schedule_los, meas_level, meas_return, memory_slots, memory_slot_size, rep_time, parameter_binds, **run_config)
220
221 # executing the circuits on the backend and returning the job
--> 222 return backend.run(qobj, **run_config)
TypeError: run() got an unexpected keyword argument 'noise_model'
Env:
macOS 10.14.6
Python 3.7.3
qiskit 0.12.0
The error is coming up because you are using BasicAer to retrieve the simulator backend. I do not think this will work with the BasicAer provider. You should be using the Aer provider.
from qiskit import Aer
qsim = Aer.get_backend('qasm_simulator')
If you just change your import statement from
from qiskit import BasicAer as Aer
to
from qiskit import Aer
then your code should work

AttributeError: 'module' object has no attribute 'version' Canopy

Hi I am going to preface this with I could just be really dumb so don't overlook that, but suddenly when opening canopy today I wasn't able to run one of my typical scripts with the error AttributeError: 'module' object has no attribute ' version' when trying to load pandas. From what I can gather it seems when bumpy is called through pandas it fails. I checked my working directory for files named numpy.py to see if I idiotically named a file numpy but failed to find such a file. I also attempted to uninstall and reinstall both numpy and pandas from the package manager in canopy. Any suggestions?
%run "/Users/jim/Documents/ORAL-PAT-2.5-3.5plotly.py"
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/Users/jim/Documents/ORAL-PAT-2.5-3.5plotly.py in <module>()
1 #import the modules you need
----> 2 import pandas as pd
3 import numpy as np
4 import plotly.plotly as py
5 import plotly.tools as tls
/Users/jim/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/__init__.py in <module>()
20
21 # numpy compat
---> 22 from pandas.compat.numpy_compat import *
23
24 try:
/Users/jim/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/compat/numpy_compat.py in <module>()
13
14 # numpy versioning
---> 15 _np_version = np.version.short_version
16 _np_version_under1p8 = LooseVersion(_np_version) < '1.8'
17 _np_version_under1p9 = LooseVersion(_np_version) < '1.9'
AttributeError: 'module' object has no attribute 'version'
Just had the same problem after downgrading Pandas and upgrading again to fix another issue. This is just a hack, but you could try this:
Open ...pandas/compat/numpy_compat.py and replace np.version.short_version with np._np_version
Hope that helps!

Categories

Resources