How to fix traceback error in Pyx module with Python? - 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).

Related

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.

Beam mongoio DisplayDataItem Value {} is of an unsupported type

When I try to write document to mongodb through
| "Write User Doc to Mongo" >> beam.io.WriteToMongoDB(uri=MONGO_URI,
db="dbname",
coll="col_name"
))
Error ValueError: Invalid DisplayDataItem. Value {} is of an unsupported type.
ERROR:root:Error while visiting Write User Doc to Mongo/ParDo(_WriteMongoFn)
Traceback (most recent call last):
File "beam_home.py", line 317, in <module>
run()
File "beam_home.py", line 312, in run
p.run().wait_until_finish()
File "/usr/local/lib/python2.7/site-packages/apache_beam/pipeline.py", line 406, in run
self._options).run(False)
File "/usr/local/lib/python2.7/site-packages/apache_beam/pipeline.py", line 419, in run
return self.runner.run_pipeline(self, self._options)
File "/usr/local/lib/python2.7/site-packages/apache_beam/runners/dataflow/dataflow_runner.py", line 469, in run_pipeline
super(DataflowRunner, self).run_pipeline(pipeline, options)
File "/usr/local/lib/python2.7/site-packages/apache_beam/runners/runner.py", line 158, in run_pipeline
pipeline.visit(RunVisitor(self))
File "/usr/local/lib/python2.7/site-packages/apache_beam/pipeline.py", line 447, in visit
self._root_transform().visit(visitor, self, visited)
File "/usr/local/lib/python2.7/site-packages/apache_beam/pipeline.py", line 824, in visit
part.visit(visitor, pipeline, visited)
File "/usr/local/lib/python2.7/site-packages/apache_beam/pipeline.py", line 824, in visit
part.visit(visitor, pipeline, visited)
File "/usr/local/lib/python2.7/site-packages/apache_beam/pipeline.py", line 827, in visit
visitor.visit_transform(self)
File "/usr/local/lib/python2.7/site-packages/apache_beam/runners/runner.py", line 153, in visit_transform
self.runner.run_transform(transform_node, options)
File "/usr/local/lib/python2.7/site-packages/apache_beam/runners/runner.py", line 196, in run_transform
return m(transform_node, options)
File "/usr/local/lib/python2.7/site-packages/apache_beam/runners/dataflow/dataflow_runner.py", line 807, in run_ParDo
transform_node.transform.output_tags)
File "/usr/local/lib/python2.7/site-packages/apache_beam/runners/dataflow/dataflow_runner.py", line 590, in _add_step
DisplayData.create_from(transform_node.transform).items])
File "/usr/local/lib/python2.7/site-packages/apache_beam/transforms/display.py", line 274, in get_dict
self.is_valid()
File "/usr/local/lib/python2.7/site-packages/apache_beam/transforms/display.py", line 246, in is_valid
.format(self.value))
ValueError: Invalid DisplayDataItem. Value {} is of an unsupported type.
It seems caused by this codes
if extra_client_params is None:
extra_client_params = {}
if not isinstance(db, str):
It seems I have to set extra_client_params of WriteToMongoDB. Is this default behavior or anything I am missing?
Unfortunately, this is a bug. There is a fix for it that will be in 2.16.0, which should be released in the next few weeks.
The main problem is right here: https://github.com/apache/beam/blob/v2.15.0/sdks/python/apache_beam/io/mongodbio.py#L472
Display data does not support dictionary-typed arguments, and we are passing the spec. To work around the bug, you'd have to override that behavior in your local Beam code unfortunately : ( - or wait a few weeks for 2.16.0 : )

TypeError: verify_file() got an unexpected keyword argument 'data_filename' (GNUPG)

I am working with gnupg in a PythonAnywhere-Django environment to run Mayan EDMS. I recently changed from using python-gnupg to the standard gnupg as to finally overcome OSErrors. However, I have found out that some syntax needs to be changed due to this process (i.e., gnupghome>homedir; gpgbinary>binary, etc.). Has anyone ever encountered the correct replacement for data_filename in the verify_file command for gnupg? I have been browsing online for some time and have seen users only inputting two arguments, as opposed to the three I use now. The file name is vital to my code.
Traceback
2019-06-13 07:22:26,695: Unexpected exception while trying to create version for new document "testassayform.xlsx" from source "Default"; verify_file() got an unexpected keyword argument 'data_filename'
Traceback (most recent call last):
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/sources/models/base.py", line 128, in upload_document
file_object=file_object, _user=user,
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/documents/models/document_models.py", line 160, in new_version
document_version.save(_user=_user)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/documents/models/document_version_models.py", line 291, in save
document_version=self
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/django/db/models/query.py", line 394, in create
obj.save(force_insert=True, using=self.db)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/document_signatures/models.py", line 111, in save
file_object=file_object
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/django_gpg/managers.py", line 118, in verify_file
file_object=file_object, keys=keys
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/django_gpg/classes.py", line 120, in verify_file
keys=keys, data_filename=data_filename
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/django_gpg/classes.py", line 82, in gpg_command
result = function(gpg=gpg, **kwargs)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/django_gpg/classes.py", line 56, in _verify_file
file=file_object, data_filename=data_filename
TypeError: verify_file() got an unexpected keyword argument 'data_filename'
2019-06-13 07:22:26,781: Error executing document upload task; verify_file() got an unexpected keyword argument 'data_filename', <class 'TypeError'>
Traceback (most recent call last):
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/sources/views.py", line 277, in forms_valid
user_id=user_id,
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/celery/app/task.py", line 565, in apply_async
link=link, link_error=link_error, **options)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/celery/app/task.py", line 763, in apply
request=request, propagate=throw)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/celery/app/trace.py", line 355, in eager_trace_task
uuid, args, kwargs, request)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/celery/app/trace.py", line 253, in trace_task
I, R, state, retval = on_error(task_request, exc, uuid)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/celery/app/trace.py", line 240, in trace_task
R = retval = fun(*args, **kwargs)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/sources/tasks.py", line 159, in task_source_handle_upload
shared_uploaded_file_id=shared_upload.pk, **kwargs
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/celery/app/task.py", line 461, in delay
return self.apply_async(args, kwargs)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/celery/app/task.py", line 565, in apply_async
link=link, link_error=link_error, **options)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/celery/app/task.py", line 763, in apply
request=request, propagate=throw)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/celery/app/trace.py", line 355, in eager_trace_task
uuid, args, kwargs, request)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/celery/app/trace.py", line 253, in trace_task
I, R, state, retval = on_error(task_request, exc, uuid)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/celery/app/trace.py", line 240, in trace_task
R = retval = fun(*args, **kwargs)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/sources/tasks.py", line 193, in task_upload_document
querystring=querystring, user=user,
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/sources/models/base.py", line 128, in upload_document
file_object=file_object, _user=user,
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/documents/models/document_models.py", line 160, in new_version
document_version.save(_user=_user)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/documents/models/document_version_models.py", line 291, in save
document_version=self
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/django/db/models/query.py", line 394, in create
obj.save(force_insert=True, using=self.db)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/document_signatures/models.py", line 111, in save
file_object=file_object
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/django_gpg/managers.py", line 118, in verify_file
file_object=file_object, keys=keys
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/django_gpg/classes.py", line 120, in verify_file
keys=keys, data_filename=data_filename
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/django_gpg/classes.py", line 82, in gpg_command
result = function(gpg=gpg, **kwargs)
File "/home/mywebsite/.virtualenvs/env/lib/python3.7/site-packages/mayan/apps/django_gpg/classes.py", line 56, in _verify_file
file=file_object, data_filename=data_filename
TypeError: verify_file() got an unexpected keyword argument 'data_filename'
classes.py (relevant function)
def verify_file(self, file_object, keys, data_filename=None):
return self.gpg_command(
function=PythonGNUPGBackend._verify_file, file_object=file_object,
keys=keys, data_filename=data_filename
)
I simply removed the verify file function altogether to bypass this problem.
However, due to further restrictions in the conversion process, I do not recommend pursuing a similar workflow as Mayan EDMS requires LibreOffice, which requires a machine or specialized host which provides that.

running matplotlib with no DISPLAY

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.

ArgumentError: An error occurred parsing (locally or remotely) the arguments to datastore_v3.Put()

My app started throwing this error last night. Users are complaining the site is slow as well. Still on Python 2.5. As far as I can tell the request itself is not unusual.
Any ideas?
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 703, in __call__
handler.post(*groups)
File "/base/data/home/apps/s~jupitersfolly/4.357517623694016771/controller/frequest.py", line 57, in post
request_types[request_type]()
File "/base/data/home/apps/s~jupitersfolly/4.357517623694016771/controller/frequest.py", line 78, in order
event, report, messages = Game.update(game_number, user_id, order)
File "/base/data/home/apps/s~jupitersfolly/4.357517623694016771/model/game.py", line 355, in update
event, report, game, universe, messages, updated, ended = db.run_in_transaction(Game.transactional_update, key_id, user_id, order)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore.py", line 2433, in RunInTransaction
return RunInTransactionOptions(None, function, *args, **kwargs)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore.py", line 2571, in RunInTransactionOptions
ok, result = _DoOneTry(new_connection, function, args, kwargs)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore.py", line 2593, in _DoOneTry
result = function(*args, **kwargs)
File "/base/data/home/apps/s~jupitersfolly/4.357517623694016771/model/game.py", line 348, in transactional_update
game.put()
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 1074, in put
return datastore.Put(self._entity, **kwargs)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore.py", line 579, in Put
return PutAsync(entities, **kwargs).get_result()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 604, in get_result
return self.__get_result_hook(self)
File "/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 1577, in __put_hook
self.check_rpc_success(rpc)
File "/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 1212, in check_rpc_success
rpc.check_success()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 570, in check_success
self.__rpc.CheckSuccess()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 133, in CheckSuccess
raise self.exception
ArgumentError: An error occurred parsing (locally or remotely) the arguments to datastore_v3.Put()

Categories

Resources