Python Jupyter nbconvert limiting printed pages - python-2.7

I am running Jupyter with a Python 2.7 kernel and I was able to get
nbconvert to run on both the command line (ipython nbconvert --to pdf file.ipynb) as well as through the jupyter browser interface.
For some reason, however, my file only prints 4 out of the 8 total pages I see on the browser. I can convert an html preview (generated by Juypter) file, and then use an online converter at pdfcrowd.com to get the full pdf files printed.
However, the online converter is lacking in latex capability.
When I installed nbconvert, I did not manually install MikTex latex for windows, as I already had it successfuly installed for Rstudio and Sweave.
I didn't want to mess with the installation.
I printed a few longer files (greater than 4 pages), without latex and a few that had latex and printed the first couple of pages fine. But that last few pages always seem to get cut off from the pdf output.
Does anyone know if that might be causing it to limit the print output, or any other ideas why?
Also, I do notice the command line prompt where jupyter is launched has a few messages...
1.599 [\text{feature_matrix}
] =
?
! Emergency stop.
<inserted text>
1.599 [\text{feature_matrix}
] =
Output written on notebook.pdf (r pages)
[NbConvertApp] PDF successfully created
I ran another file and saw the output showed
!you can't use 'macro parameter character #,' in restricted horizontal mode.
...ata points }}{\mbox{# totatl data points}}
?
! Emergency stop
Look like it is somehow choking on using the latex character #
then halting publishing. But it at least publishes all the pages prior to the error and emergency stop.
While not a solution, I manually changed the latex symbol # to number and
the entire file printed. I wonder if this is a problem with my version of latex maybe?
halted pdf job
$$\mbox{accuracy} = \frac{\mbox{# correctly classified data points}}{\mbox{# total data points}}$$
passed pdf job
$$\mbox{accuracy} = \frac{\mbox{number correctly classified data points}}{\mbox{number total data points}}$$
edit: if it help anyone, I used the suggestion here, to use a backslash escape character before the #, to solve the issue; so it looks like it is a latex issue, if that helps anyone.

Related

pagedown::chrome_print() extremely slow for some xaringan html slides

I'm creating pdf versions of html slides generated from R markdown files. I've come across a puzzling behaviour. When I run pagedown::chrome_print on the html with output specified as xaringan::moon_reader, the operation fails with the timeout message:
Error in force(expr) : Failed to generate output in 30 seconds (timeout)
Here is an example of a call to convert such a xaringan html file which produces this timeout error on my machine:
pagedown::chrome_print("https://stat540-ubc.github.io/lectures/lectures_2020/lect09_MultipleTesting.html")
The Rmd source for this html is located here. If I increase the timeout argument of chrome_print to something very large (several thousand), the operation appears to take a lot of resources (computer fans turn on, machine becomes hot), but the pdf output is eventually produced. However, if I instead change the output to slidy_presentation in the Rmd instead of xaringan::moon_reader, chrome_print runs successfully on the html and produces a pdf in just a few seconds (with no change to the default timeout argument).
I have the same issue with other slide decks that I have created with a similar template to the one I linked above, but this doesn't happen with every xaringan html file. For example, I am able to use chrome-print to successfully convert this xaringan html file to pdf (with no change to the default timeout argument):
pagedown::chrome_print("https://annakrystalli.me/talks/xaringan/xaringan.html")
Other things I tried:
I installed decktape and used the xaringan::decktape on the xaringan html file, which also produced a timeout error. Though I'm not sure how to increase the time using this method, so I don't know if it would eventually work if given enough time.
I tried using the latest versions of Google Chrome and Chromium with the chrome_print function and got the same results as described above. I'm using Mac OSX 10.15.5.
I would like to stick with xaringan html slides as they have some features I prefer. However, the current method of conversion to pdf is not sustainable for me since I will need to convert many similar htmls, as well as update them periodically. If anyone has come across this or can suggest what might be causing this extreme slowdown when converting my xaringan htmls to pdfs, I'd appreciate your input.

Stata do files in Atom (script package)

I am trying to run a do file in Atom (macOS). The script package detects the language correctly but is "unable to run".
Atom is started from the terminal, script works for other languages and Stata is on PATH.
Any idea what might be going wrong?
Just to note, the issue can also be solved on Windows by editing grammars.coffee as well, the default path being C:/Users/*username*/.atom/packages/script/lib/ and changing "stata" to the location of Stata on the machine. Highlighted text also doesn't work, as each line is executed in Stata with quotes around it, meaning Stata will interpret it as a single command name, not as a command with arguments.
Figured it out: .
The code of the script package needs to be modified. In the grammars.coffee file, I replaced both commands of Stata by "/Applications/Stata/StataSE.app/Contents/MacOS/StataSE". Works fine now.
Adding Stata to the path variable is not sufficient (might not be necessary even).
This works for me too — but I use StataMP so updated the filepath as such to /Applications/Stata/StataMP.app/Contents/MacOS/StataMP and things are working fine now.
That said, I'm not sure if script supports this, but when executing a highlighted selection of code in a .do file crashes my StataMP 14.2

Running Python programs in python.exe, the command prompt, and IDLE

Let me preface this post that I am incredibly new to python. I took a course in codeacademy but haven't actually used python on my own computer until now. Let me also explain to everyone that my coding experience is limited to VBA and excel. I have very little knowledge of how to use the command prompt, how libraries work, etc, etc.
I'm having some issues. I've changed my directory to recognize python when I type python in my command prompt. Then I can do simple things like
print "hello"
however if i write something like this
def firstfunction(t):
print t+5
return
firstfunction(5)
I would expect this to print the number 10, however I get the following error:
File"stdin", line 4
first function(5)
^
syntaxerror: invalid syntax
However if I use this in IDLE and run it it works fine.
Next I've saved some python programs I wrote. One I saved as Hello.py
i want to run this code from my python exe or from the command prompt but can't figure out how.
Please any answers helpful, if you use computer lingo, try and keep it as simple as possible. I'm super new!
Thanks
If the location of python is not included in your path, add it. But in any case, you should be able to run this successfully from the directory containing your python.exe.
e.g, if python lives in C:\Python27:
cd C:\Python27
python mypythonscript.py

Matplotlib failing while text.usetex==True

I want to use Latex to create greek symbols in plot labels. However any attempt to set e.g.
rcParams['text.usetex'] = True
or any other version of this I could find, results in a screen full of errors even for plots in which labels aren't even used. If I set it back to False everything is fine. I know I should "post my attempt" but I emphasize that every example on this forum and any other webpage I can find that claims to achieve the objective fails.
The final error on the pages of errors is that type1cm.sty is not found. Using tex Live utility I see I have it installed.
Would appreciate help for novices here as I am not exactly computer savvy.
In response to below - I am using a Mac OSX version 10.9.5. The usual program I use for my Tex stuff is TexShop version 3.18.
Since it would appear that the iPython notebook is having problems with finding the type1cm.sty file, I would assume there is some method to tell it how to find it.

Open python file with Task scheduler

I have a .py file that reads integers from a separate csv , i just cant launch it from windows task scheduler, after 2 days and much frustration im posting here. A lot of similar questions have been posted but none are answered adequately for my case.
I have no problems launching other python files or exe's, the problem arises when the python file needs to read a csv. I have turned the file into a batch file, and i have also went through every possible permutation of administration and permission options, but still no cigar. The problem stems solely from the fact that the python needs to call from an external csv. Has anyone got an opinion, or a work-around?
Thanks.
Assuming that you try this under the windows 7 Task-scheduler...
You may try the following:
In the security options of your Task (1st page) ensure that you have selected the SYSTEM account. Tick the high privileges check box near the bottom of the dialog (i guess you already did that)
check if the file can be accessed (write into it with notepad)
try to call the executable from the python processor directly with your script-file as an argument (maybe something went wrong with the inheritance of access rights when windows calls the python processor; assuming that you linked the .py file in the Task Scheduler)
check the execution profile of the python command processor and compare it to the ownership of the CSV file (does the csv file reside in a user-account folder and has therefor other access requirements the python process can provide ? example: csv owned by user X, Task is run as user Y)
you may also try to create a new, empty textfile somewhere else (C:) and fill the content in from the CSV
greetings :)