I'm not sure if this is an issue because charts are currently being updated in Bokeh but I can no longer plot a complete dataframe using Line charts from Bokeh in my Jupyter notebook. Using this example from the docs:
from collections import OrderedDict
import numpy as np
import pandas as pd
from bokeh.charts import Line
from bokeh.plotting import show, output_file
from bokeh.charts import Chart, Line
xyvalues = OrderedDict(
python=[2, 3, 7, 5, 26, 221, 44, 233, 254, 265, 266, 267, 120, 111],
pypy=[12, 33, 47, 15, 126, 121, 144, 233, 254, 225, 226, 267, 110, 130],
jython=[22, 43, 10, 25, 26, 101, 114, 203, 194, 215, 201, 227, 139, 160],
)
# any of the following commented are valid Line inputs
xyvalues = pd.DataFrame(xyvalues)
#xyvalues = xyvalues.values()
#xyvalues = np.array(xyvalues.values())
output_file("lines.html", title="line.py example")
chart = Line(xyvalues, title="Lines", ylabel='measures', legend=True)
show(chart)
I get: Incorrect dataframe plot which is clearly different to the example shown in the docs.
If I explicitly give the dataframe an index and pass all the columns like below then it gives the expected plot:
xyvalues = pd.DataFrame(xyvalues, index=range(14))
output_file("lines.html", title="line.py example")
chart = Line(xyvalues, y=['python', 'pypy', 'jython'],
title="Lines", ylabel='measures', legend=True)
show(chart)
My notebook specs:
You are using Jupyter notebook.
The version of the notebook server is 4.0.6 and is running on:
Python 2.7.11 |Anaconda 2.4.1 (64-bit)| (default, Dec 6 2015, 18:08:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
IPython 4.0.1 -- An enhanced Interactive Python.
Updating to 0.11.0dev4 through conda fixed the issue.
conda install -c bokeh/channel/dev bokeh
Related
Hi am trying to run a scraper on ubuntu/windows machine .
I have installed scrapy version- Scrapy 1.8.0 on using python2.
I am able create a project, but when I run a scraper this error in shown.
Traceback (most recent call last):
File "/home/ubuntu/.local/bin/scrapy", line 8, in <module>
sys.exit(execute())
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/cmdline.py", line 146, in execute
_run_print_help(parser, _run_command, cmd, args, opts)
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/cmdline.py", line 100, in _run_print_help
func(*a, **kw)
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/cmdline.py", line 154, in _run_command
cmd.run(args, opts)
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/commands/shell.py", line 68, in run
crawler.engine = crawler._create_engine()
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/crawler.py", line 111, in _create_engine
return ExecutionEngine(self, lambda _: self.stop())
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/core/engine.py", line 67, in __init__
self.scheduler_cls = load_object(self.settings['SCHEDULER'])
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/utils/misc.py", line 46, in load_object
mod = import_module(module)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/core/scheduler.py", line 7, in <module>
from queuelib import PriorityQueue
File "/home/ubuntu/.local/lib/python2.7/site-packages/queuelib/__init__.py", line 1, in <module>
from queuelib.queue import FifoDiskQueue, LifoDiskQueue
File "/home/ubuntu/.local/lib/python2.7/site-packages/queuelib/queue.py", line 7, in <module>
from contextlib import suppress
ImportError: cannot import name suppress
can anyone help to solve this issue?
The contextlib.suppress function supports from Python 3.4 but you are using Python 2.7. To solve this problem, upgrade your python version.
If this is useful for someone else, the solution for me (also using python 2.7) was:
pip uninstall attrs
pip uninstall queuelib
pip install queuelib==1.5.0
pip install attrs
I had followed the following instructions for setting up google-cloud-ml on LOCAL: MAC/LINUX
google-cloud-ml setup
But I am getting the following errors while verifying the setup with this command
curl https://raw.githubusercontent.com/GoogleCloudPlatform/cloudml-samples/master/tools/check_environment.py | python
Traceback (most recent call last):
File "", line 70, in
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/google/cloud/ml/init.py", line 16, in
from google.cloud.ml.dataflow._analyzer import AnalyzeModel
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/google/cloud/ml/dataflow/init.py", line 22, in
from _ml_transforms import DeployVersion
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/google/cloud/ml/dataflow/_ml_transforms.py", line 24, in
import _ml_functions as ml_func
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/google/cloud/ml/dataflow/_ml_functions.py", line 25, in
from google.cloud.ml.io.coders import TrainingJobResult
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/google/cloud/ml/io/init.py", line 21, in
from transforms import LoadFeatures
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/google/cloud/ml/io/transforms.py", line 23, in
from google.cloud.ml.dataflow.io import tfrecordio
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/google/cloud/ml/dataflow/io/init.py", line 15, in
import tfrecordio
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/google/cloud/ml/dataflow/io/tfrecordio.py", line 16, in
_crc32c_fn = snappy._crc32c # pylint: disable=protected-access
AttributeError: 'module' object has no attribute '_crc32c'
Looks like there is some issue with dataflow library of google cloud.
I tried upgrading the dataflow library with the following command
pip install --upgrade google-api-python-client
but now, another error. Following is the stacktrace:
Traceback (most recent call last):
File "", line 70, in
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/google/cloud/ml/init.py", line 16, in
from google.cloud.ml.dataflow._analyzer import AnalyzeModel
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/google/cloud/ml/dataflow/init.py", line 17, in
from _analyzer import AnalyzeModel
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/google/cloud/ml/dataflow/_analyzer.py", line 19, in
import apache_beam as beam
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/apache_beam/init.py", line 78, in
from apache_beam import io
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/apache_beam/io/init.py", line 21, in
from apache_beam.io.avroio import *
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/apache_beam/io/avroio.py", line 29, in
from apache_beam.io import filebasedsource
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/apache_beam/io/filebasedsource.py", line 32, in
from apache_beam.io import concat_source
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/apache_beam/io/concat_source.py", line 24, in
from apache_beam.io import iobase
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/apache_beam/io/iobase.py", line 853, in
from apache_beam.runners.dataflow.native_io.iobase import *
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/apache_beam/runners/init.py", line 23, in
from apache_beam.runners.dataflow_runner import DataflowRunner
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/apache_beam/runners/dataflow_runner.py", line 32, in
from apache_beam.internal import json_value
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/apache_beam/internal/json_value.py", line 20, in
from apitools.base.py import extra_types
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/apitools/base/py/init.py", line 23, in
from apitools.base.py.credentials_lib import *
File "/Users/pratyusha/miniconda2/envs/cloudml/lib/python2.7/site-packages/apitools/base/py/credentials_lib.py", line 50, in
from oauth2client import locked_file
This looks like a different version of 'snappy' is expected. Can you check which version of python-snappy you have installed?
You can do this by running:
pip freeze | grep python-snappy
It worked for me with version 0.5, which is the latest version. If you have an earlier version, try running:
pip install --upgrade python-snappy
(using 'sudo' or '--user' as necessary.)
This question already has answers here:
Setting Matplotlib MPLCONFIGDIR: consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data
(2 answers)
Closed 6 years ago.
I am getting following error then I run application:
File "/var/opt/igp_modules/Mod51_LAM/mod51_LAM.py", line 235, in process
self.linesStructureCSV(inlist)
File "/var/opt/igp_modules/Mod51_LAM/mod51_LAM.py", line 610, in linesStructureCSV
from line_analysis import LAM
File "/var/opt/igp_modules/Mod51_LAM/line_analysis.py", line 2, in <module>
import pandas as pd
File "/usr/lib64/python2.6/site-packages/pandas/__init__.py", line 44, in <module>
from pandas.core.api import *
File "/usr/lib64/python2.6/site-packages/pandas/core/api.py", line 9, in <module>
from pandas.core.groupby import Grouper
File "/usr/lib64/python2.6/site-packages/pandas/core/groupby.py", line 17, in <module>
from pandas.core.frame import DataFrame
File "/usr/lib64/python2.6/site-packages/pandas/core/frame.py", line 41, in <module>
from pandas.core.series import Series
File "/usr/lib64/python2.6/site-packages/pandas/core/series.py", line 2909, in <module>
import pandas.tools.plotting as _gfx
File "/usr/lib64/python2.6/site-packages/pandas/tools/plotting.py", line 28, in <module>
import pandas.tseries.converter as conv
File "/usr/lib64/python2.6/site-packages/pandas/tseries/converter.py", line 7, in <module>
import matplotlib.units as units
File "/usr/lib64/python2.6/site-packages/matplotlib/__init__.py", line 709, in <module>
rcParams = rc_params()
File "/usr/lib64/python2.6/site-packages/matplotlib/__init__.py", line 627, in rc_params
fname = matplotlib_fname()
File "/usr/lib64/python2.6/site-packages/matplotlib/__init__.py", line 565, in matplotlib_fname
fname = os.path.join(get_configdir(), 'matplotlibrc')
File "/usr/lib64/python2.6/site-packages/matplotlib/__init__.py", line 240, in wrapper
ret = func(*args, **kwargs)
File "/usr/lib64/python2.6/site-packages/matplotlib/__init__.py", line 439, in _get_configdir
raise RuntimeError("Failed to create %s/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data"%h)
RuntimeError: Failed to create /root/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data
but from terminal pandas is imported successfully.
[iv2user#develpoment-24 igp_modules]$ python manage.py shell
Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import pandas
>>> import matplotlib
>>>
How can I fix this issue?
Server details:
OS: CentOS 6.8
Pandas: 0.17.1
Numpy: 1.11.1rc1
Read the last line of the error message:
RuntimeError: Failed to create /root/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data
matplotlib needs a writable location, and its trying to write to /root/.matplotlib and your django server probably doesn't have permission to write there because its not running as root (which is a good thing. Don't run as root just to defeat this).
You've not said how you've launched django (via apache? some other server?) but the fix would seem to be to set that environment variable to a location owned by the user that your django process runs as - possible user www or apache or something else.
I'm trying to use theano but I get an error when I import it.
I've installed cuda_6.5.14_linux_64.run, and passed all the recommended test in Chapter 6 of this NVIDIA PDF.
Ultimately I want to be able to install pylearn2, but I get the exact same error as below when I try to compile it.
EDIT1: My theanorc looks like:
[cuda]
root = /usr/local/cuda-6.5
[global]
device = gpu
floatX=float32
If I replace gpu with cpu, the command import theano succeeds.
Python 2.7.8 |Anaconda 1.9.0 (64-bit)| (default, Aug 21 2014, 18:22:21)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
Imported NumPy 1.9.1, SciPy 0.14.0, Matplotlib 1.3.1
Type "scientific" for more details.
>>> import theano
Using gpu device 0: GeForce GTX 750 Ti
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/g/anaconda/lib/python2.7/site-packages/theano/__init__.py", line 92, in <module>
theano.sandbox.cuda.tests.test_driver.test_nvidia_driver1()
File "/home/g/anaconda/lib/python2.7/site-packages/theano/sandbox/cuda/tests/test_driver.py", line 28, in test_nvidia_driver1
profile=False)
File "/home/g/anaconda/lib/python2.7/site-packages/theano/compile/function.py", line 223, in function
profile=profile)
File "/home/g/anaconda/lib/python2.7/site-packages/theano/compile/pfunc.py", line 512, in pfunc
on_unused_input=on_unused_input)
File "/home/g/anaconda/lib/python2.7/site-packages/theano/compile/function_module.py", line 1312, in orig_function
defaults)
File "/home/g/anaconda/lib/python2.7/site-packages/theano/compile/function_module.py", line 1181, in create
_fn, _i, _o = self.linker.make_thunk(input_storage=input_storage_lists)
File "/home/g/anaconda/lib/python2.7/site-packages/theano/gof/link.py", line 434, in make_thunk
output_storage=output_storage)[:3]
File "/home/g/anaconda/lib/python2.7/site-packages/theano/gof/vm.py", line 847, in make_all
no_recycling))
File "/home/g/anaconda/lib/python2.7/site-packages/theano/sandbox/cuda/__init__.py", line 237, in make_thunk
compute_map, no_recycling)
File "/home/g/anaconda/lib/python2.7/site-packages/theano/gof/op.py", line 606, in make_thunk
output_storage=node_output_storage)
File "/home/g/anaconda/lib/python2.7/site-packages/theano/gof/cc.py", line 948, in make_thunk
keep_lock=keep_lock)
File "/home/g/anaconda/lib/python2.7/site-packages/theano/gof/cc.py", line 891, in __compile__
keep_lock=keep_lock)
File "/home/g/anaconda/lib/python2.7/site-packages/theano/gof/cc.py", line 1322, in cthunk_factory
key=key, fn=self.compile_cmodule_by_step, keep_lock=keep_lock)
File "/home/g/anaconda/lib/python2.7/site-packages/theano/gof/cmodule.py", line 996, in module_from_key
module = next(compile_steps)
File "/home/g/anaconda/lib/python2.7/site-packages/theano/gof/cc.py", line 1237, in compile_cmodule_by_step
preargs=preargs)
File "/home/g/anaconda/lib/python2.7/site-packages/theano/sandbox/cuda/nvcc_compiler.py", line 444, in compile_str
return dlimport(lib_filename)
File "/home/g/anaconda/lib/python2.7/site-packages/theano/gof/cmodule.py", line 284, in dlimport
rval = __import__(module_name, {}, {}, [module_name])
ImportError: ('The following error happened while compiling the node', GpuCAReduce{add}{1}(<CudaNdarrayType(float32, vector)>), '\n', '/home/g/.theano/compiledir_Linux-3.11.0-26-generic-x86_64-with-debian-wheezy-sid-x86_64-2.7.8-64/tmpWYqQw5/7173b40d34b57da0645a57198c96dbcc.so: undefined symbol: __fatbinwrap_66_tmpxft_00004bf1_00000000_12_cuda_device_runtime_compute_50_cpp1_ii_5f6993ef', '[GpuCAReduce{add}{1}(<CudaNdarrayType(float32, vector)>)]')
I encountered exactly the same question.
My solution is to replace cuda-6.5 with cuda-5.5, and everything works fine.
We also saw this error. We found that putting /usr/local/cuda-6.5/bin in $PATH seemed to fix it (even with the root = ... line in .theanorc).
I am trying to render an SVG map using Kartograph.py. It throws me the TypeError. Here is the python code:
import kartograph
from kartograph import Kartograph
import sys
from kartograph.options import read_map_config
css = open("stylesheet.css").read()
K = Kartograph()
cfg = read_map_config(open("config.json"))
K.generate(cfg, outfile='dd.svg', format='svg', stylesheet=css)
Here is the error it throws
Traceback (most recent call last):
File "<pyshell#33>", line 1, in <module>
K.generate(cfg, outfile='dd.svg', format='svg', stylesheet=css)
File "C:\Python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\kartograph.py", line 46, in generate
_map = Map(opts, self.layerCache, format=format)
File "C:\Python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\map.py", line 61, in __init__
layer.get_features()
File "C:\Python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\maplayer.py", line 81, in get_features
charset=layer.options['charset']
File "C:\Python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\layersource\shplayer.py", line 121, in get_features
geom = shape2geometry(shp, ignore_holes=ignore_holes, min_area=min_area, bbox=bbox, proj=self.proj)
File "C:\Python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\layersource\shplayer.py", line 153, in shape2geometry
geom = shape2polygon(shp, ignore_holes=ignore_holes, min_area=min_area, proj=proj)
File "C:\Python27\lib\site-packages\kartograph.py-0.6.8-py2.7.egg\kartograph\layersource\shplayer.py", line 217, in shape2polygon
poly = MultiPolygon(polygons)
File "C:\Python27\lib\site-packages\shapely\geometry\multipolygon.py", line 74, in __init__
self._geom, self._ndim = geos_multipolygon_from_polygons(polygons)
File "C:\Python27\lib\site-packages\shapely\geometry\multipolygon.py", line 30, in geos_multipolygon_from_polygons
N = len(ob[0][0][0])
TypeError: 'Polygon' object does not support indexing
I had a look at shapely and it seems like you are using an outdated version.
Update your current install:
pip install -U shapely