I am trying to get my jupyter notebook to convert to pdf so I can submit it, and am having an awfully hard time doing so. I first installed nbconvert and pypandoc and then I downloaded the pandoc zip folder on their website (the installer wasn't working) and put it in my path. I was initially getting the message
nbconvert failed: Pandoc wasn't found. Please check that pandoc is installed: http://pandoc.org/installing.html
but doing those steps fixed it. I am now getting the following message. I did a workaround solution by print previewing, saving the html page, and then converting the html page to pdf, but it would still be nice to fix this. Thanks!
nbconvert failed: PDF creating failed, captured latex output:
Failed to run "xelatex .\notebook.tex -quiet" command:
This is XeTeX, Version 3.14159265-2.6-0.999992 (TeX Live 2020/W32TeX) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
! Undefined control sequence.
<*> .\notebook
.tex -quiet
?
! Emergency stop.
<*> .\notebook
.tex -quiet
No pages of output.
Transcript written on ?.
I solved with
pip install --upgrade --user nbconvert
Related
New to Jupyter Notebook and trying to download the .ipynb file as a PDF via LaTex. I am trying to use pre-made templates so that the code in the cells aren't getting cut off at the margins when it converts to a PDF file. So far, I have tried two solutions (listed below) but running into errors, maybe someone can point me in the right direction?
Attempted Solution #1:
I followed the README in a pre-made template here: https://github.com/t-makaro/nb_pdf_template
Then in Jupyter Notebook: File > Download As > PDF via LaTex and get this error, see screenshot below. Am I placing the template files in the wrong folder and thus Jupyter Notebook is somehow not picking it up?
Attempted Solution #2:
I followed the steps in this guy's solution also:
https://www.markus-beuckelmann.de/blog/customizing-nbconvert-pdf.html
but then I get some error: ! LaTeX Error: File `tcolorbox.sty' not found.
I tried replicating the error following the steps at the GitHub linked on a Google Colab notebook. I've added the installation of additional libraries that are needed by nbconvert in order to unlock further capabilities.
!pip install nb_pdf_template
!python -m nb_pdf_template.install
!apt-get install texlive-xetex texlive-fonts-recommended texlive-plain-generic
!jupyter nbconvert --to pdf ../testing.ipynb --template classic
This works without any problems on my end.
I am trying to download github dataset from here:
https://raw.githubusercontent.com/heyunh2015/PARADE_dataset/main/PARADE_test.txt
using a windows machine, and the anaconda host to play jupyter notebook, I am trying to directly download it in the machine using the following command:
!wget https://raw.githubusercontent.com/heyunh2015/PARADE_dataset/main/PARADE_test.txt
However, it is giving me the following error:
'wget' is not recognized as an internal or external command, operable
program or batch file.
Then I tried again after the following command:
!pip install wget
still the same error.
Next, I tried curl, and the error went away, but I am unable to access my downloaded file either through code (the file doesn't exist) or using GUI (doesn't show up in the current working directory).
What to do?
I got my answer.
import wget
url = "<source>"
wget.download(url, '<destination>')
wget not working in annaconda jupyter notebook - Windows. Alternative?
python's standard library has function for downloading files, called urlretrieve inside urllib.request. Simple usage example
import urllib.request
urllib.request.urlretrieve("https://raw.githubusercontent.com/heyunh2015/PARADE_dataset/main/PARADE_test.txt","PARADE_test.txt")
Explanation: 2 arguments are provided, URL and filename. Note that in this form this does not report progress. You need to wait until it finishes. If you must have see linked docs for discussion of 3rd argument to urllib.request.urlretrieve
After pip3 installing nbconvert and jupyter and installing MacTex, I still have the following error, which wouldnt allow me to export to PDF:
Could anyone provide assistance? Thank you
You can export it to HTML and then using the Print to PDF feature of your browser like the message suggested.
If you insist to export it to PDF directly. After you install the MacTex you need to restart your computer, and make sure the installation path of MacTex can be found in your VSCode terminal, xelatex command can be recognized. Like this picture displays(Windows):
I have a Google Colaboratory Notebook for Data Analysis that I want to output as a HTML file as currently not everything loads within the Colab environment such as large Folium Heatmaps. Is it possible to export the notebook as a html file as opposed to the ipynb and py options?
Method using Google Colab only
Download your .ipynb file
You can actually do it using only Google Colab. File -> Download .ipynb
Reupload it so Colab can see it
Click on the Files icon on the far left:
Then Upload to session storage:
Select & upload your .ipynb file you just downloaded.
Get your file's path
then obtain its path (you might need to hit the Refresh button before your file shows up):
Conversion using %%shell
Then, just as in Julio's answer, execute in a Colab cell:
%%shell
jupyter nbconvert --to html /PATH/TO/YOUR/NOTEBOOKFILE.ipynb
The %%shell lets the interpreter know that the following script is interpreted as shell. Don't write anything before %%shell, use a distinct cell for this.
The form of /PATH/TO/YOUR/NOTEBOOKFILE.ipynb will be something like /content/lightaberration3.ipynb.
Your file is ready
Might need to click Refresh again, but your notebook.html will appear in the files, so you can download it:
The great thing about this is that nothing python-related has to be installed on your computer, not conda, not pip, only a browser.
Google Colab doesn't currently have such a feature as a built-in.
Your best route is to first download it through File > Download .ipynb and then use the standard tool for Jupyter Notebook conversion, nbconvert:
jupyter nbconvert --to html notebook.ipynb
If you use an Anaconda Python distribution, nbconvert is most likely already installed. If not, refer to what is described in their install instructions to be able to convert:
pip install nbconvert
# OR
conda install nbconvert
to continue with "Method using only Google Colab"
" %%shell jupyter nbconvert --to html /PATH/TO/YOUR/NOTEBOOKFILE.ipynb" - as given
the following worked for me - type the following in Google Colab
!pip install nbconvert
%shell jupyter nbconvert --to html /content/testfile.ipynb
(instead of using %%shell in Google Colab, use %shell - this way, it worked for me)
Download your notebook and upload it back to the colab
Replace PATH_TO_THE_NOTEBOOK_IN_COLAB in the below command to the location of the reuploaded notebook.
Use this command to download the notebook as html => !jupyter nbconvert --to html PATH_TO_THE_NOTEBOOK_IN_COLAB.ipynb.
I tried the approach above but couldn't get it to work - for small jobs I log onto https://jupyter.org/try , upload the downloaded ipynb file from Google Colab and then I opened the file, from here you will have the functionality in jupyter.org to download as html or whatever other format you require. It took the pain out of trying to get it to work.
I was trying to convert .ipynb to a pdf.
I'm on Windows and use Jupyter via IE browser.
I'm following the link http://pandoc.org/installing.html to install Pandoc.
Here's what I have done: Any suggestions?
Install MikTex: http://miktex.org/download
Install pandoc
Install stack:
-got to cmd from pandoc folder, run stack setup
-stack init
-stack install---->ERRORS!!
If you would like an alternative to it instead of using nbconvert what you can do is :
Download your ipynb file as HTML from File option.
Right-click and select print or use Ctrl+P.
Save as PDF
Easy.