I am able to compile an invoice with the following command:
pandoc details.yml -o output.pdf --template=invoice.tex --latex-engine=xelatex
But when I write the same thing in Python, I get an error complaning about the input format:
>>> pypandoc.convert_file('details.yml', 'pdf', outputfile='pyout.pdf', extra_args=['--latex-engine=xelatex', '--template=invoice.tex'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/pypandoc/__init__.py", line 140, in convert_file
outputfile=outputfile, filters=filters)
File "/usr/local/lib/python3.6/site-packages/pypandoc/__init__.py", line 262, in _convert_input
format, to = _validate_formats(format, to, outputfile)
File "/usr/local/lib/python3.6/site-packages/pypandoc/__init__.py", line 223, in _validate_formats
_get_base_format(format), ', '.join(from_formats)))
RuntimeError: Invalid input format! Got "yml" but expected one of
these: commonmark, docbook, docx, epub, haddock, html, json, latex, markdown, markdown_github, markdown_mmd, markdown_phpextra, markdown_strict, mediawiki, native, odt, opml, org, rst, t2t, textile, twiki
What am I doing wrong here? Why is yml not accepted?
Figured it out by reading the source.
So it turns out that this is due to a design decision made by the pypandoc developers. The program infers the type of the input from the file extension, so the only way to pass a yaml file is to rename it with a .md-extension.
https://github.com/bebraw/pypandoc/blob/ffe82646d2ab6cc4e732960a1e1af6bfcb760bb1/pypandoc/init.py#L202
Related
I am trying to read s2p files in using Python scikit-rf library. The s2p file in not in S parameter. I converted it to Z parameter. Looks like scikit-rf can read only S parameter file. Is there any other library or way to read s2p files with Z parameter. Below is how I am reading the file:
import skrf as rf
ntwk = rf.Network('ZTEST5_SHORTED.s10p')
s = ntwk.s
print(s)
Below is the error:
Traceback (most recent call last):
File "C:\Users\pujai\PycharmProjects\SIIntegration\practice.py", line 26, in <module>
ntwk = rf.Network('ZTEST5_SHORTED_DCfitted.s10p')
File "C:\Users\pujai\PycharmProjects\SIIntegration\venv\lib\site-packages\skrf\network.py", line 457, in __init__
self.read_touchstone(filename, self.encoding)
File "C:\Users\pujai\PycharmProjects\SIIntegration\venv\lib\site-packages\skrf\network.py", line 2050, in read_touchstone
raise NotImplementedError('only s-parameters supported for now.')
NotImplementedError: only s-parameters supported for now.
If I try to read an S parameter file, it works fine. Any help?
I need to extract a single file (~10kB) from many very large RAR files (>1Gb). The code below shows a basic implementation of how I'm doing this.
from rarfile import RarFile
rar_file='D:\\File.rar'
file_of_interest='Folder 1/Subfolder 2/File.dat'
output_folder='D:/Output'
rardata = RarFile(rar_file)
rardata.extract(file_of_interest, output_folder)
rardata.close()
However, the extract instruction is returning the following error: rarfile.BadRarFile: Failed the read enough data: req=16384 got=52
When I open the file using WinRAR, I can extract the file successfully, so I'm sure the file isn't corrupted.
I've found some similar questions, but not a definite answer that worked for me.
Can someone help me to solve this error?
Additional info:
Windows 10 build 1909
Spyder 5.0.0
Python 3.8.1
Complete traceback of the error:
Traceback (most recent call last):
File "D:\Test\teste_rar_2.py", line 27, in <module>
rardata.extract(file_of_interest, output_folder)
File "C:\Users\bernard.kusel\AppData\Local\Continuum\anaconda3\lib\site-packages\rarfile.py", line 826, in extract
return self._extract_one(inf, path, pwd, True)
File "C:\Users\bernard.kusel\AppData\Local\Continuum\anaconda3\lib\site-packages\rarfile.py", line 912, in _extract_one
return self._make_file(info, dstfn, pwd, set_attrs)
File "C:\Users\bernard.kusel\AppData\Local\Continuum\anaconda3\lib\site-packages\rarfile.py", line 927, in _make_file
shutil.copyfileobj(src, dst)
File "C:\Users\bernard.kusel\AppData\Local\Continuum\anaconda3\lib\shutil.py", line 79, in copyfileobj
buf = fsrc.read(length)
File "C:\Users\bernard.kusel\AppData\Local\Continuum\anaconda3\lib\site-packages\rarfile.py", line 2197, in read
raise BadRarFile("Failed the read enough data: req=%d got=%d" % (orig, len(data)))
BadRarFile: Failed the read enough data: req=16384 got=52
I am trying to write TextClip into a video with moviepy. It has always been working, yet after I reinstalled ffmpeg, it doesn't work anymore (I am not sure whether it has caused it, but I mentioned it in case it does). Some of the TextClip objects are pure spaces.
I got the following error message:
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\video\VideoClip.py", line 1137, in __init__
subprocess_call(cmd, logger=None)
File "C:\Users\USER\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\tools.py", line 54, in subprocess_call
raise IOError(err.decode('utf8'))
OSError: magick.exe: no images for write '-write' 'PNG32:C:\Users\USER\AppData\Local\Temp\tmpmnf0fkb5.png' at CLI arg 14 # error/operation.c/CLINoImageOperator/4893.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "media_main_user.py", line 79, in <module>
insert_audio_and_subtitles(input_clip,'output.mp4','text.mp3',subtitles,fontsize=subtitles_font_size,
File "D:\UserData\Desktop\Project\影片剪輯\關鍵字版本\make_media.py", line 318, in insert_audio_and_subtitles
annotated_clips = [annotate(video.subclip(from_t, to_t), txt) for (from_t, to_t), txt in subtitles]
File "D:\UserData\Desktop\Project\影片剪輯\關鍵字版本\make_media.py", line 318, in <listcomp>
annotated_clips = [annotate(video.subclip(from_t, to_t), txt) for (from_t, to_t), txt in subtitles]
File "D:\UserData\Desktop\Project\影片剪輯\關鍵字版本\make_media.py", line 311, in annotate
txtclip = TextClip(txt, fontsize=fontsize, font=font, color=txt_color)
File "C:\Users\USER\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\video\VideoClip.py", line 1146, in __init__
raise IOError(error)
OSError: MoviePy Error: creation of None failed because of the following error:
magick.exe: no images for write '-write' 'PNG32:C:\Users\USER\AppData\Local\Temp\tmpmnf0fkb5.png' at CLI arg 14 # error/operation.c/CLINoImageOperator/4893.
.
.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or that the path you specified is incorrect
I have tried to solve the problems multiple ways, like checking the config-default.py file in moviepy installation directory, and the path for ImageMagick it's pointing to is not wrong. I tried to reinstall ImageMagick, it is also of no use. And I tried to edit the policy.xml file in ImageMagick directory from none to read|write, but it also doesn't work. Can anyone suggest other possible solutions?
In /etc/ImageMagick-6/policy.xml try to comment out the following line altogether:
<policy domain="path" rights="none" pattern="#*" />
Like so:
<!-- <policy domain="path" rights="none" pattern="#*" /> -->
I am starting with Microsoft Azure SDK for Python (https://github.com/Azure/azure-sdk-for-python), but I have problems.
I am using Scientific Linux and I have installed the SDK for Python 3.4 following the next steps:
(instead of the SDK directory)
python setup.py install
after that I created a simple script just to test the connection:
from azure.storage import BlobService
blob_service = BlobService(account_name='thename', account_key='Mxxxxxxx3w==' )
blob_service.create_container('testcontainer')
for i in blob_service.list_containers():
print(i.name)
following this documentation:
http://blogs.msdn.com/b/tconte/archive/2013/04/17/how-to-interact-with-windows-azure-blob-storage-from-linux-using-python.aspx
http://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/#large-blobs
but is not working, I always receive the same error:
python3 test.py
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/storageclient.py", line 143, in _perform_request
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/storageclient.py", line 132, in _perform_request_worker
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/http/httpclient.py", line 247, in perform_request
azure.http.HTTPError: The value for one of the HTTP headers is not in the correct format.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 21, in <module>
blob_service.create_container('testcontainer')
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/blobservice.py", line 192, in create_container
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/__init__.py", line 905, in _dont_fail_on_exist
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/blobservice.py", line 189, in create_container
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/storageclient.py", line 150, in _perform_request
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/__init__.py", line 889, in _storage_error_handler
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/__init__.py", line 929, in _general_error_handler
azure.WindowsAzureError: Unknown error (The value for one of the HTTP headers is not in the correct format.)
<?xml version="1.0" encoding="utf-8"?><Error><Code>InvalidHeaderValue</Code><Message>The value for one of the HTTP headers is not in the correct format.
RequestId:b37c5584-0001-002b-24b8-c2c245000000
Time:2014-11-19T14:54:38.9378626Z</Message><HeaderName>x-ms-version</HeaderName><HeaderValue>2012-02-12</HeaderValue></Error>
Thanks in advance and best regards.
I have this exact same issue. I believe it's a library bug, but the author/s haven't had their say yet.
It looks like the response states the version, but it's actually giving you the header that's wrong. Its value should be "2014-02-14", you can do the fix shown in https://github.com/Azure/azure-sdk-for-python/pull/289 .
Hopefully this will be fixed and nobody will ever read this answer. Cheers!
I am attempting to generate bindings for a WSDL with PyXB, and it is giving the AssertionError exception in the title.
My understanding, based on the PyXB documentation, is that the bundle archive for http://www.w3.org/1999/xhtml is included with PyXB. However, something appears to be wrong. It either does not get used, or it has incorrect contents.
I use the following command line to attempt to generate the bindings:
python c:\Python27\Scripts\pyxbgen.py --wsdl-location=http://xx.xxx.xxx.xxx/YYY.asmx?WSDL --module=client --write-for-customization
The traceback:
Traceback (most recent call last):
File "c:\Python27\Scripts\pyxbgen.py", line 51, in <module> generator.resolveExternalSchema()
File "c:\Python27\lib\site-packages\pyxb\binding\generate.py", line 2647, in resolveExternalSchema
schema = converter(self, sl)
File "c:\Python27\Scripts\pyxbgen.py", line 28, in WSDLToSchema
spec = wsdl.definitions.createFromDOM(pyxb.utils.domutils.StringToDOM(xmld,
location_base=wsdl_uri), process_schema=True, generation_uid=generator.generationUID())
File "c:\Python27\lib\site-packages\pyxb\binding\basis.py", line 1767, in createFromDOM
return self._createFromDOM(node, expanded_name, **kw)
File "c:\Python27\lib\site-packages\pyxb\binding\basis.py", line 1791, in _createFromDOM
return element.CreateDOMBinding(node, self.elementForName(expanded_name), **kw)
File "c:\Python27\lib\site-packages\pyxb\binding\basis.py", line 1735, in elementForName
assert 'elementBinding' in elt_en.namespace()._categoryMap(), 'No element bindings in %s' % (elt_en.namespace(),)
AssertionError: No element bindings in http://www.w3.org/1999/xhtml
In addition, I set the PYXB_ARCHIVE_PATH environment variable to:
C:\Python27\Lib\site-packages\pyxb\bundles\common\raw
I am not sure if this is the correct way to do this. I also tried specifying the --archive-path command line option as well, but I got the same error back.
Probably you need to use:
--archive-path=${PYXB_ROOT}/pyxb/bundles/common//:+
as the argument. This recursively searches for available namespaces in the common bundles first, then includes any other search paths. There's an example in the manual that's close to this.