Image Magic not generating thumbnail for first page of PDF Files - pdf

I have downloaded the Image Magic from the following Link:
http://www.imagemagick.org/download/linux/CentOS/i386/ImageMagick-6.9.1-3.i386.rpm
Extracted the rpm file using rpm2cpio ImageMagick-6.9.1-3.i386.rpm | cpio -idmv
Running below command to create the thumbnail for the first page of PDF
convert source.pdf[0] output.jpg
But I am getting error:
convert: No match.
Anyone has any idea why it is not working? What I am doing wrong?

Instead of installing ImageMagick, you have extracted it instead. What you would want to do is install it.
You could run yum install ImageMagick to install it, which will take care of all the necessary dependencies as well. Or, if you wanted to install using the rpm, you should run rpm -i ImageMagick-6.9.1-3.i386.rpm. I would suggest going through the yum route instead, however.
Note: The above answer is based upon the assumption that you are using CentOS or RedHat or a similar distribution. If you are using Ubuntu or a similar distribution, you would need to use apt-get install imagemagick.

Related

running the singularity image and finding the results

I am trying to make the image for the Singularity using the following file(which is Singularity.recepie):
Bootstrap: docker
From: ubuntu:18.04
%post
apt-get -y update
apt-get install -y python3-pip
%files
QC.py /
%runscript
python3 /QC.py
I build the image using the following command:
sudo singularity build ubuntu.simg Singularity.recepie
and run the image using this command:
./ubuntu.simg
when I run the image it works but I do not see the result files in the directory that I am working at. do you know how I can the results and copy them to my current directory?
By default, your current working directory is mounted into the image and used as the working directory. If no files are being created and they should be, then you need to look at where your script is trying to write to. Also check the singularity error/warnings output for additional info.
If you're using an older version of Singularity (implied by .simg instead of .sif extension), you may also be running on a kernel that does not support overlayfs, which can cause issues attempting to mount to a non-existing folder. If this is the case, singularity will give a warning but continue on and possibly fail in a hard to detect manner. More info on mounting with overlay here.

IPython/Jupyter Problems saving notebook as PDF

So, I've been trying to save a jupyter notebook as PDF but I just can't figure out how to do this. The first thing I try is from the file menu just download as PDF, but doing that results in:
nbconvert failed: PDF creating failed
the next thing I try is try to do the conversion from the Command Prompt like this
$ ipython nbconvert --to latex --post PDF MyNotebook.ipynb
but again, this results in an error message
ImportError: No module named 'PDF'
and if I try
$ ipython nbconvert --to latex MyNotebook.ipynb
this results in
IPython.nbconvert.utils.pandoc.PandocMissing: Pandoc wasn't found:
Please check that pandoc is installed
if I try to install pandoc (pip install pandoc), this gives me
ImportError: No module named 'ConfigParser'
and this is where I get stuck because I just don't know what else to do.
Anyone have idea how to fix whatever is wrong?
To make it work, I installed latex, typical latex extra, and pandoc.
With ubuntu:
sudo apt-get install texlive texlive-latex-extra pandoc
it takes some times: several 100 Mb to download. I read somewhere that you can use --no-install-recommends for texlive and extra to reduce to the dl.
If you are on a Mac and have Homebrew installed, open a terminal shell and install pandoc typing the command:
brew install pandoc
be patient, time to install and compile can take a while on slow internet connections or older systems.
To convert notebooks to PDF you first need to have nbconvert installed.
pip install nbconvert
# OR
conda install nbconvert
Next, if you aren't using Anaconda or haven't already, you must install pandoc either by following the instructions on their website or, on Linux, as follows:
sudo apt-get install pandoc
After that you need to have XeTex installed on your machine:
Linux : TeX Live
Mac : MacTex
Windows : MikTex
You can now navigate to the folder that holds your IPython Notebook and run the following command:
jupyter nbconvert --to pdf MyNotebook.ipynb
for further reference, please check out this link.
2015-4-22: It looks like an IPython update means that --to pdf should be used instead of --to latex --post PDF. There is a related Github issue.
For converting any Jupyter notebook to PDF, please follow the below instructions:
(Be inside Jupyter notebook):
On Mac OS:
command + P --> you will get a print dialog box --> change destination as PDF --> Click print
On Windows:
Ctrl + P --> you will get a print dialog box --> change destination as PDF --> Click print
If the above steps doesn't generate full PDF of the Jupyter notebook (probably because Chrome, some times, don't print all the outputs because Jupyter make a scroll for big outputs),
Try performing below steps for removing the auto scroll in the menu:-
Credits: #ÂngeloPolotto
In your Jupyter Notebook, click Cell on top of the jupyter notebook
Next click All output --> Toggle scrolling for removing auto scroll.
As the comments to the question say, you will need pandoc and latex (e.g. TeXShop). I installed pandoc with Homebrew, it took just a second. Having pandoc and TeXShop, I could generate latex but not pdf (on the command line).
ipython nbconvert --to latex mynotebook.ipynb
Exploring the latex (.tex) file with TeXShop, the failure was due to missing stylesheets and defs. After installing all of these (adjustbox.sty, adjcalc.sty, trimclip.sty, collectbox.sty, tc-pgf.def, ucs.sty, uni-global.def, utf8x.def, ucsencs.def), it did finally work.
However, the result looks a little too funky for my taste. It is too bad that printing the html from Safari loses the syntax coloring. Otherwise, it doesn't look so bad. (This is all on OS X).
I am using Anaconda-Jupyter Notebook on OS: Ubuntu 16.0 for Python programming.
Install Nbconvert, Pandoc, and Tex:
Open a terminal and implement the following commands in it.
Install Nbconvert: though it's part of the Jupyter ecosystem still install it once again
$conda install nbconvert
Or
$pip install nbconvert
But I will recommend using conda instead pip if you are using anaconda
Install Pandoc: since Nbconvert uses Pandoc for converting markdown to formats other than HTML. Type following command
$sudo apt-get install pandoc
Install TeX: For converting to PDF, nbconvert uses the TeX. Type following command
$sudo apt-get install texlive-xetex
After execution of these commands, close the opened notebooks refresh the home page Or restart the kernel of the opened notebook. Now try to download notebook as a pdf :)
Note: For more details, please refer the official documentation:
https://nbconvert.readthedocs.io/en/latest/install.html
This Python script has GUI to select with explorer a Ipython Notebook you want to convert to pdf. The approach with wkhtmltopdf is the only approach I found works well and provides high quality pdfs. Other approaches described here are problematic, syntax highlighting does not work or graphs are messed up.
You'll need to install wkhtmltopdf:
http://wkhtmltopdf.org/downloads.html
and
Nbconvert
pip install nbconvert
# OR
conda install nbconvert
Python script
# Script adapted from CloudCray
# Original Source: https://gist.github.com/CloudCray/994dd361dece0463f64a
# 2016--06-29
# This will create both an HTML and a PDF file
import subprocess
import os
from Tkinter import Tk
from tkFileDialog import askopenfilename
WKHTMLTOPDF_PATH = "C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf" # or wherever you keep it
def export_to_html(filename):
cmd = 'ipython nbconvert --to html "{0}"'
subprocess.call(cmd.format(filename), shell=True)
return filename.replace(".ipynb", ".html")
def convert_to_pdf(filename):
cmd = '"{0}" "{1}" "{2}"'.format(WKHTMLTOPDF_PATH, filename, filename.replace(".html", ".pdf"))
subprocess.call(cmd, shell=True)
return filename.replace(".html", ".pdf")
def export_to_pdf(filename):
fn = export_to_html(filename)
return convert_to_pdf(fn)
def main():
print("Export IPython notebook to PDF")
print(" Please select a notebook:")
Tk().withdraw() # Starts in folder from which it is started, keep the root window from appearing
x = askopenfilename() # show an "Open" dialog box and return the path to the selected file
x = str(x.split("/")[-1])
print(x)
if not x:
print("No notebook selected.")
return 0
else:
fn = export_to_pdf(x)
print("File exported as:\n\t{0}".format(fn))
return 1
main()
notebook-as-pdfInstall
python -m pip install notebook-as-pdf pyppeteer-install
Use it
You can also use it with nbconvert:
jupyter-nbconvert --to PDFviaHTML filename.ipynb
which will create a file called filename.pdf.
or pip install notebook-as-pdf
create pdf from notebook jupyter-nbconvert-toPDFviaHTML
This problem was experienced with both Ubuntu and Mac OSX. After a frantic set of searches and trials, both of them were solved. This requires both tex and pandoc; both jumbo external programs cannot installed by Python's pip.
Mac OSX: using MacPorts installation of pandoc
port install pandoc
This should take nearly an hour to complete (in the usual case). If the problem persists, you might have to install MacTeX distro. of TeXLive.
For Ubuntu: install vanilla TeXLive from the network installer -- not through apt-get. Then install pandoc using apt-get.
sudo apt-get install pandoc
A complete installation of TeXLive would require a upto to 4.4 GB on disk.
To save all this trouble, the recommeded way to use IPython/Jupyter Notebook would be to install Anaconda Python distribution.
I had all kinds of problems figuring this out as well. I don't know if it will provide exactly what you need, but I downloaded my notebook as an HTML file, then pulled it up in my Chrome browser, and then printed it as a PDF file, which I saved. It captured all my code, text and graphs. It was good enough for what I needed.
If you are using sagemath cloud version, you can simply go to the left corner,
select File --> Download as --> Pdf via LaTeX (.pdf)
Check the screenshot if you want.
Screenshot Convert ipynb to pdf
If it dosn't work for any reason, you can try another way.
select File --> Print Preview and then on the preview
right click --> Print and then select save as pdf.
As a brand new member, I was unable to simply add a comment on the post but I want to second that the solution offered by Phillip Schwartz worked for me. Hopefully people in a similar situation will try that path sooner with the emphasis. Not having page breaks was a frustrating problem for quite a while so I am grateful for the discussion above.
As Phillip Schwartz said:
"You'll need to install wkhtmltopdf: [http://wkhtmltopdf.org/downloads.html][1]
and Nbconvert "
You then add a cell of the type "rawNBConvert" and include:
<p style="page-break-after:always;"></p>
That seemed to do the trick for me, and the generated PDF had the page break at the corresponding locations.
You don't need to run the custom code though, as it seems the "normal" path of downloading the notebook as HTML, opening in browser, and printing to PDF works once those utilities are installed.
To convert .ipynb into pdf, your system should contain 2 components,
nbconvert:
Is part of jupyter allows to convert ipynb to pdf
pip install nbconvert
OR
conda install nbconvert
XeTeX:
Convert ipynb to .tex format and then converting to pdf.
sudo apt-get install texlive-xetex
Then you can use below command to convert to pdf,
ipython nbconvert --to pdf YOURNOTEBOOK.ipynb
In case, it doesn't work, install pandoc and try again.
sudo apt-get install pandoc
I had problems correctly displaying some symbols with regular download as pdf. So downloaded as tex jupyter nbconvert --to latex "my notebook.ipynb", made some tweaks with notepad (as an example, in my case I needed these lines for my language
\usepackage{tgpagella}
\usepackage[lithuanian,english]{babel}
) and then exported to pdf with latex --output-format=pdf "my notebook.tex".
But finally, however, to retain the same characters as you see in a browser I ended up using my Chrome browser printing: Ctrl+P Print to pdf. It adds unnecessary header and footer but everything else remains as it is. No more errors processing tqdm progress bar, no more code going out of the page and so on. Simple as that.
In any system, the basic steps to correctly setup nbconvert to convert ipython notebooks to pdf/latex are
Install nbconvert
Install pandoc
Install Texlive
Installing nbconvert
pip install nbconvert
or conda install nbconvert
Installing pandoc
sudo apt-get install pandoc for Ubuntu
or sudo yum install pandoc for CentOS
for others visit pandoc-installation
Installing texlive
You can install recommended packages or full install. For Ubuntu
sudo apt-get install texlive texlive-xetex texlive-generic-extra texlive-generic-recommended
`
For others and to full install texlive follow the instructions given at tug as per your system and choice.
I downloaded tar.gz file from tug-texlive-download and followed instructions given at TeX Live - Quick install. Installation instructions in summary:
Clean up
rm -rf /usr/local/texlive/2019
rm -rf ~/.texlive2019
Run installer
unpack the zip file
cd /your/unpacked/directory
perl install-tl
Enter command: i
Setting path
sudo vi /etc/bash.bashrc and insert
PATH=/usr/local/texlive/2019/bin/x86_64-linux:$PATH; export PATH
MANPATH=/usr/local/texlive/2019/texmf-dist/doc/man:$MANPATH; export MANPATH
INFOPATH=/usr/local/texlive/2019/texmf-dist/doc/info:$INFOPATH; export INFOPATH
Setting default papersize
tlmgr paper letter
The commands may differ as per your system but the basic steps remains the same.
I had this error in Windows 10. I followed these three steps and it solved my problem:
Install nbconvert
pip install nbconvert
Install pandoc
https://pandoc.org/installing.html
Install miktex
https://miktex.org/download
Also it is good to update libraries:
pip install jupyter --upgrade
pip install --upgrade --user nbconvert
What I found was that the nbconvert/utils/pandoc.py had a code bug that resulted in the error for my machine. The code checks if pandoc is in your environmental variables path. For my machine the answer is no. However pandoc.exe is!
Solution was to add '.exe' to the code on line 69
if __version is None:
if not which('pandoc.exe'):
raise PandocMissing()
The same goes for 'xelatex' is not installed.
Add to the file nbconvert/exporters/pdf.py on line 94
cmd = which(command_list[0]+'.exe')
For Ubuntu users, an answer can be found here. I also quote it:
The most probable cause, is that you have not installed the
appropriate dependencies. Your Ubuntu system has to have some packages
installed regarding conversion of LaTeX and XeTeX files, in order to
save your notebook as PDF. You can install them by:
sudo apt-get install texlive texlive-xetex texlive-generic-extra texlive-generic-recommended pandoc
Also, nbconvert is another dependency that is usually automatically
installed with jupyter. But you can install it just to be sure, while
having your virtual environment activated:
pip install -U nbconvert
You may go for below simple trick (works totally well with all modern browsers; on all recent operating systems - Windows, Mac, Linux) :
Right click anywhere on your ipynb notebook.
Select Print... . This will take you to the "Print-Preview Wizard" that will show you a PDF form of your python notebook.
Provide the destination folder name. Click save.
Voila!!
This simple hack shall ofcourse save much of your time of installing nbviewer or miktex, pandoc or LaTex, etc. converter packages. Moreover, actually this hack works in same way, like you try to save an html webpage into PDF format.

How to install opera-stable_26.0.1656.60_amd64.deb in centos6

I have downloaded opera-stable_26.0.1656.60_amd64.deb and searched how to install the same in my centos6.Got several links but none of them gave actual method.Please provide a suitable solution. I have tried with following command
yum install opera-stable_26.0.1656.60_amd64.deb
You could try using this script to convert the deb to an rpm:
http://ruario.ghost.io/2014/12/20/my-christmas-present-to-opera-fans-on-rpm-distros/

yum install, select and link a specific version of a software

Suppose I want to install python2.7 with yum, and do
sudo yum install python27
This will install a python2.7 in the /usr/bin directory. However, the symbolic link /usr/bin/python still points to python2.6.
Is there a yum command that can manage this symbolic link rather than doing it manually? I know the port select in MacPorts does so, and am looking for a counterpart in yum. Thanks a lot!
Unless the distribution has been set up to handle this sort of thing (the way debian and some others are) you do not want to be changing the default value of something like /usr/bin/python because you will break anything the distribution packages which depends on the default python being the version of python in the default python package.
Things built against the python27 package almost certainly use /usr/bin/python2.7 when they need to run python scripts and/or on their shebang lines. Things packaged by the default system almost certainly just use /usr/bin/python assuming that is the default system python version.

Specifying download dir with yum downloadonly

I'm trying to run the following:
yum reinstall glibc --downloadonly --downloaddir=/root/dependencies/
But it keeps giving me an error that --downloaddir is not a valid option though I've seen others use it around the web. I'm using RHEL Workstation 5.5. Is there another way to specify the downloaddir?
Thanks
first install yumdownloader
yum install yumdownloader