running matplotlib with no DISPLAY - python

When matlplotlib run (from summarize_taxa_through_plots.py) I got the error:
...
raise RuntimeError('Invalid DISPLAY variable')
RuntimeError: Invalid DISPLAY variable
I saw this problem in a lot of sites, the solution is to change user's matplotlirc or global one:
backend:qt4agg
to
backend:agg
I change the global matplotlibrc.
Now when I run the program use matplotlib I get:
Command returned exit status: 1
Stdout:
Stderr
Traceback (most recent call last):
File "/path/to/python/2.7.6/bin/plot_taxa_summary.py", line 278, in <module>
main()
File "/path/to/python/2.7.6/bin/plot_taxa_summary.py", line 274, in main
resize_nth_label, label_type, include_html_legend)
File "/path/to/python/2.7.6/lib/python2.7/site-packages/qiime/plot_taxa_summary.py", line 1138, in make_all_charts
resize_nth_label, label_type, include_html_legend))
File "/path/to/python/2.7.6/lib/python2.7/site-packages/qiime/plot_taxa_summary.py", line 1073, in get_counts
label_type, include_html_legend))
File "/path/to/python/2.7.6/lib/python2.7/site-packages/qiime/plot_taxa_summary.py", line 861, in make_HTML_table
props={'title': title})
File "/path/to/python/2.7.6/lib/python2.7/site-packages/qiime/plot_taxa_summary.py", line 662, in make_area_bar_chart
background_color, img_abs, generate_image_type, dpi)
File "/path/to/python/2.7.6/lib/python2.7/site-packages/qiime/plot_taxa_summary.py", line 187, in make_legend
shadow=False, fancybox=False)
File "/path/to/python/2.7.6/lib/python2.7/site-packages/matplotlib/figure.py", line 1251, in legend
l = Legend(self, handles, labels, *args, **kwargs)
File "/path/to/python/2.7.6/lib/python2.7/site-packages/matplotlib/legend.py", line 385, in __init__
self._init_legend_box(handles, labels, markerfirst)
File "/path/to/python/2.7.6/lib/python2.7/site-packages/matplotlib/legend.py", line 654, in _init_legend_box
fontsize, handlebox))
File "/path/to/python/2.7.6/lib/python2.7/site-packages/matplotlib/legend_handler.py", line 119, in legend_artist
fontsize, handlebox.get_transform())
File "/path/to/python/2.7.6/lib/python2.7/site-packages/matplotlib/legend_handler.py", line 252, in create_artists
self.update_prop(p, orig_handle, legend)
File "/path/to/python/2.7.6/lib/python2.7/site-packages/matplotlib/legend_handler.py", line 78, in update_prop
legend._set_artist_props(legend_handle)
File "/path/to/python/2.7.6/lib/python2.7/site-packages/matplotlib/legend.py", line 401, in _set_artist_props
a.set_figure(self.figure)
File "/path/to/python/2.7.6/lib/python2.7/site-packages/matplotlib/artist.py", line 640, in set_figure
raise RuntimeError("Can not put single artist in "
RuntimeError: Can not put single artist in more than one figure
Any idea?

The suggestion is to downgrade the matplotlib version you have and to use something like 1.4.x. See this issue in the qiime GitHub repo.

Related

Miniconda: cannot launch spyder

I have always been able to launch spyder without any issues. But today I started running into the following error messages. I don't understand why is it complaining no workingdir? How do I resolve this, as I cannot even launch spyder ?
Traceback (most recent call last):
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\Scripts\spyder-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\start.py", line 253, in main
mainwindow.main(options, args)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\mainwindow.py", line 1956, in main
mainwindow = create_window(MainWindow, app, splash, options, args)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\utils.py", line 289, in create_window
main.setup()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\mainwindow.py", line 771, in setup
PLUGIN_REGISTRY.register_plugin(self, PluginClass,
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\plugin_registration\registry.py", line 342, in register_plugin
instance = self._instantiate_spyder5_plugin(
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\plugin_registration\registry.py", line 193, in _instantiate_spyder5_plugin
plugin_instance.initialize()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\plugins\new_api.py", line 669, in initialize
self.on_initialize()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\plugins\workingdirectory\plugin.py", line 82, in on_initialize
container.set_history(
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\plugins\workingdirectory\container.py", line 323, in set_history
workdir = self._get_init_workdir()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\plugins\workingdirectory\container.py", line 183, in _get_init_workdir
workdir = self.get_conf('startup/fixed_directory')
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\config\mixins.py", line 76, in get_conf
return CONF.get(section, option, default)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\config\manager.py", line 499, in get
value = config.get(section=section, option=option, default=default)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\config\user.py", line 980, in get
return config.get(section=section, option=option, default=default)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\config\user.py", line 511, in get
raise cp.NoSectionError(section)
configparser.NoSectionError: No section: 'workingdir'

Python buildozer, ValueError

Good afternoon! I'm asking for help, I can't figure out python buildozer for a day, I've already prepared everything, and at the final stage, when the "buildozer android debug" command is entered into the terminal, it gives such an error at the end. Can anyone tell me what to do about it and how to fix it?
Here is the error itself:
Traceback (most recent call last):
File "/usr/local/bin/buildozer", line 11, in <module>
load_entry_point('buildozer==0.40.dev0', 'console_scripts', 'buildozer')()
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/scripts/client.py", line 13, in main
Buildozer().run_command(sys.argv[1:])
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/__init__.py", line 1071, in run_command
self.target.run_commands(args)
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/target.py", line 92, in run_commands
func(args)
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/target.py", line 102, in cmd_debug
self.buildozer.prepare_for_build()
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/__init__.py", line 178, in prepare_for_build
self.target.install_platform()
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/targets/android.py", line 666, in install_platform
self._install_android_ndk()
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/targets/android.py", line 459, in _install_android_ndk
cwd=self.buildozer.global_platform_dir)
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/__init__.py", line 699, in download
urlretrieve(url, filename, report_hook)
File "/usr/lib/python3.6/urllib/request.py", line 1826, in retrieve
block = fp.read(bs)
File "/usr/lib/python3.6/tempfile.py", line 624, in func_wrapper
return func(*args, **kwargs)
ValueError: read of closed file
I tried to find an answer to this question, but so far without success.

Using cartopy in offline distributable

I have made a simple application/GUI using PyQt5 that draws a map using Cartopy and allows users to drop points on the map. Everything works fine when I have access to Wifi. I used pyinstaller to bundle it up as one application so I can send it to my friends.
However, if you do not have access to the internet, cartopy is unable to draw the map because it cannot access the shapefiles which it downloads into the ~.local/share/cartopy/shapefiles location. I tried including the shapefiles using the --add-data command in pyinstaller but it didn't work?
I used sys._MEIPASS to include a CSV of other data, and it works just fine to read that data (coordinates of some landmarks).
The error looks something like:
File "site-packages\matplotlib\backends\backend_agg.py", line 393, in draw
File "site-packages\matplotlib\artist.py", line 38, in draw_wrapper
File "site-packages\matplotlib\figure.py", line 1735, in draw
File "site-packages\matplotlib\image.py", line 137, in _draw_list_compositing_images
File "site-packages\matplotlib\artist.py", line 38, in draw_wrapper
File "site-packages\cartopy\mpl\geoaxes.py", line 479, in draw
File "site-packages\matplotlib\artist.py", line 38, in draw_wrapper
File "site-packages\matplotlib\axes\_base.py", line 2630, in draw
File "site-packages\matplotlib\image.py", line 137, in _draw_list_compositing_images
File "site-packages\matplotlib\artist.py", line 38, in draw_wrapper
File "site-packages\cartopy\mpl\feature_artist.py", line 155, in draw
File "site-packages\cartopy\feature\__init__.py", line 302, in intersecting_geometries
File "site-packages\cartopy\feature\__init__.py", line 110, in intersecting_geometries
File "site-packages\cartopy\feature\__init__.py", line 284, in geometries
File "site-packages\cartopy\io\shapereader.py", line 295, in natural_earth
File "site-packages\cartopy\io\__init__.py", line 222, in path
File "site-packages\cartopy\io\shapereader.py", line 350, in acquire_resource
File "site-packages\cartopy\io\__init__.py", line 261, in _urlopen
File "urllib\request.py", line 222, in urlopen
File "urllib\request.py", line 525, in open
File "urllib\request.py", line 542, in _open
File "urllib\request.py", line 502, in _call_chain
File "urllib\request.py", line 1393, in https_open
File "urllib\request.py", line 1353, in do_open
urllib.error.URLError: <urlopen error [Errno 11001] getaddrinfo failed>
In the code itself, I have:
os.chdir(sys._MEIPASS)
datapath1 = 'data\\ne_50m_coastline.shp'
And further below
coastline = datapath1
map.add_feature(coastline, zorder=3)
But, as shown in the error above, when I run the executable with no internet access, it does not find the shapefile included in the exe onefile.
Thanks in advance for any help!

How to fix traceback error in Pyx module with Python?

I am trying to run in PyX module in Python.
It is a simple program called "mplot.py":
from pyx import *
g = graph.graphxy(width=8)
g.plot(graph.data.function("y(x)=sin(x)/x", min=-15, max=15))
g.writePDFfile("function")
I want to do this to make plot.
I run it as normal
C:\Users\Tony>py myplot.py
But I get strange and long error message:
Traceback (most recent call last):
File "myplot.py", line 4, in <module>
g.writePDFfile("function")
File "C:\Users\Tony\Programs\Python\Python37-32\lib\sitepackages\pyx\canvas.py", line 50, in wrappedindocument
return method(d, file, **write_kwargs)
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\document.py", line 193, in writePDFfile
pdfwriter.PDFwriter(self, f, **kwargs)
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\pdfwriter.py", line 316, in __init__
catalog = PDFcatalog(document, self, registry)
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\pdfwriter.py", line 143, in __init__
self.PDFpages = PDFpages(document, writer, registry)
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\pdfwriter.py", line 202, in __init__
page = PDFpage(page, pageno, self, writer, registry)
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\pdfwriter.py", line 236, in __init__
self.PDFcontent = PDFcontent(page, writer, self.pageregistry)
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\pdfwriter.py", line 268, in __init__
page.processPDF(contentfile, awriter, acontext, registry, self.bbox)
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\document.py", line 135, in processPDF
self._process("processPDF", *args)
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\document.py", line 129, in _process
getattr(cc, processMethod)(contentfile, writer, context, registry, bbox)
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\graph\graph.py", line 191, in processPDF
canvas.canvas.processPDF(self, file, writer, context, registry, bbox)
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\canvas.py", line 238, in processPDF
item.processPDF(file, writer, context, registry, nbbox)
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\canvas.py", line 238, in processPDF
item.processPDF(file, writer, context, registry, nbbox)
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\canvas.py", line 238, in processPDF
item.processPDF(file, writer, context, registry, nbbox)
[Previous line repeated 1 more time]
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\text.py", line 887, in processPDF
self.dvicanvas.processPDF(file, writer, context, registry, abbox)
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\text.py", line 851, in dvicanvas
self.do_finish()
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\text.py", line 1212, in do_finish
self.go_finish()
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\text.py", line 1338, in go_finish
self._execute("\\end%\n", self.texmessages_end_default +
self.texmessages_end, STATE_TYPESET, STATE_DONE)
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\text.py", line 1125, in _execute
raise e
File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
packages\pyx\text.py", line 1103, in _execute
raise TexResultError("TeX dvifile messages expected")
pyx.text.TexResultError: TeX dvifile messages expected
The expression passed to TeX was:
\end%
After parsing the return message from TeX, the following was left:
*(see the transcript file for additional information)
Output written on "C:\Users\Tony\Temp\pyx3z6ter8i\texp
ut.dvi" (25 pages, 1800 bytes).
Transcript written on "C:\Users\Tony\Temp\pyx3z6ter8i\
texput.log".
How to fix this error and get my plot?
How to fix this error and get my plot?
How to fix this error and get my plot?How to fix this error and get my plot?
How to fix this error and get my plot?
How to fix this error and get my plot?
How to fix this error and get my plot?
How to fix this error and get my plot?
How to fix this error and get my plot?
How to fix this error and get my plot?How to fix this error and get my plot?How to fix this error and get my plot?
How to fix this error and get my plot?How to fix this error and get my plot?
Any help is much appreciated. Thank you
You can fix it by adding the line
text.set(engine=text.TexEngine, texmessages_end=[text.texmessage.ignore])
immediately after the import statement. However, this will just silence the issue. A proper fix will be part of a future PyX release (see https://github.com/pyx-project/pyx/issues/8).

Does tf_debug truly support slim?

I have written the following code:
tf.contrib.slim.learning.train(
...
...
session_wrapper=tensorflow.python.debug.LocalCLIDebugWrapperSession,
...)
While running the code, it reported:
......
......
2018-02-14 01:03:25.229477: I tensorflow/core/debug/debug_graph_utils.cc:229] For debugging, tfdbg is changing the parallel_iterations attribute of the Enter/RefEnter node "lstm/lstm_1/while/Enter_2" on device "/job:localhost/replica:0/task:0/device:CPU:0" from 32 to 1. (This does not affect subsequent non-debug runs.)
Traceback (most recent call last):
File "train_getimageid_ngch.py", line 147, in <module>
tf.app.run()
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "train_getimageid_ngch.py", line 143, in main
saver=saver)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/contrib/slim/python/slim/learning.py", line 775, in train
sv.stop(threads, close_summary_writer=True)
File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/supervisor.py", line 964, in managed_session
self.stop(close_summary_writer=close_summary_writer)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/supervisor.py", line 792, in stop
stop_grace_period_secs=self._stop_grace_secs)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/coordinator.py", line 389, in join
six.reraise(*self._exc_info_to_raise)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/coordinator.py", line 296, in stop_on_exception
yield
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/coordinator.py", line 494, in run
self.run_loop()
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/supervisor.py", line 1068, in run_loop
global_step=self._sv.global_step)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1549, in save
global_step = training_util.global_step(sess, global_step)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/training_util.py", line 67, in global_step
return int(sess.run(global_step_tensor))
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/debug/wrappers/framework.py", line 543, in run
run_end_resp = self.on_run_end(run_end_req)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/debug/wrappers/local_cli_wrapper.py", line 321, in on_run_end
self._dump_root, partition_graphs=partition_graphs)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/debug/lib/debug_data.py", line 495, in __init__
self._load_all_device_dumps(partition_graphs, validate)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/debug/lib/debug_data.py", line 517, in _load_all_device_dumps
self._load_partition_graphs(partition_graphs, validate)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/debug/lib/debug_data.py", line 798, in _load_partition_graphs
self._validate_dump_with_graphs(debug_graph.device_name)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/debug/lib/debug_data.py", line 843, in _validate_dump_with_graphs
"device %s." % (datum.node_name, device_name))
ValueError: Node name 'TFRecordReaderV2' is not found in partition graphs of device /job:localhost/replica:0/task:0/device:CPU:0.
Even it can start the tf debugger, when tried to print the value of a tensor, i.e. the pt command, it reported the error:
Error occured during handling of command: "print_tensor"
exceptions.KeyError /device:CPU:0
Is it possible for tf_debug to truly support slim? How can it be worked out? If not, is there any other way to debug or print the values of tensors when using tf.contrib.slim.learning.train?

Categories

Resources