pdflatex is not installed in google colab - google-colaboratory

I'm trying to use lcapy's python library to draw some electrical circuits in google colab. Unfortunately, I'm always getting an error:
RuntimeError: pdflatex is not installed
Even though I did pip install pdflatex
I couldn't find anything related to this error in lcapy's docs.
the notebook can be found here

I experienced a similar issue/error trying to render PDFs from latex output generated by pandas in google colab recently. The error I got was complaining about a file (Error Code 2), listed 'pdflatex' as the missing file, but I confirmed the install had completed as you reported. This led me to realize there were missing LaTex dependencies that were generating the error; the traceback seemed a bit misleading to me. Here is the solution that worked for me:
First, install components and dependencies in colab notebook:
!pip install folium==0.2.1
!pip install pdflatex
!sudo apt-get install texlive-latex-recommended
!sudo apt install texlive-latex-extra
!sudo apt install dvipng
In my first attempt, There was an error buried in the install of pdflatex with an incompatible version of folium 0.8.x, so the first command rolls it back to the compatible version from the error trace. Probably not totally necessary to roll back folium, but I haven't tested.
The latex install commands were shamelessly lifted from this answer for latex-equations-do-not-render-in-google-colaboratory-when-using-matplotlib, where they offer a bit more explanation. The whole install process produced quite a bit of output and took some time.
After completed, I was able to generate a pdf file from my LaTex string similar to the example from the package docs:
import pdflatex as ptex
pdfl = ptex.PDFLaTeX.from_texfile(r'/content/my_tex_string_file.tex')
pdf, log, completed_process = pdfl.create_pdf()
with open('testPDF.pdf', 'wb') as pdfout:
pdfout.write(pdf)
my_tex_string_file.tex was generated from pandas in my test case, and I added a preamble manually (string concatenation) to include the correct latex packages for my desired output, but a quick look through the github page for lcapy shows the same approach may work for lcapy as well.

I ran into the same issue myself and after verifying pdflatex is installed with !pdflatex -help, I looked into Lcapy's code. The easiest workaround I found is to comment out line 73 of system.py. I only need schematic tools, so this solution is adequate for me. If you need a proper solution, all the relevant functions are in the same file and it seems that import pdflatex is unnecessary as the library searches for the binary.

Related

plotnine is broken with matplotlib==3.6

I am getting the following error with plotnine==0.9 and matplotlib==3.6.
File "D:\Python\Python310\lib\site-packages\plotnine\stats\stat_density_2d.py", line 3, in <module>
import matplotlib._contour as _contour
ModuleNotFoundError: No module named 'matplotlib._contour'
If I downgrade matplotlib==3.5, the problem goes away.
It's discussed here and it's already fixed here Note that it's already merged to main.
It was due to a internal matplotlib call that is no longer supported and has been replaced.
So I guess you could choose between:
downgrade to mlp 3.5.3
install plotnine#main
till the next plotnine release.
Carlos's answer is correct. However if anybody else, like me, is uncertain of how to install plotnine#main, you can implement the fix rather easily:
Find the site_packages folder you python script uses. It usually is a subdirectory of the python version you are using, which can located reliably by trying to reinstall matplotlib or any other package you know you have access to, and checking the logs in the console. ex using python -m pip install matplotlib.
Go down into the site_packages/plotnine/stats directory and open up the stats_density_2d.py file in your editor of choice.
Apply & save the modifications made in the fix. Alternatively, overwrite the file with the one from the github.
ModuleNotFoundError: No module named 'matplotlib._contour'
Issues with matplotlib 3.6.1 and
plotnine 0.9.0
K.I.S.S.
in terminal:
pip show matplotlib #enables you to check version
pip install matplotlib==3.5 #revert and problem is resolved for now.
no more:
ModuleNotFoundError: No module named 'matplotlib._contour'
resolves issue for now that will stop progress...

Library not loaded: #rpath/libtbb.dylib in Prophet / Python

I'm on a Mac X1, Monterey.
I've installed prophet and run into this issue when trying to fit a model.
RuntimeError: Error during optimization: console log output:
dyld[90668]: Library not loaded: #rpath/libtbb.dylib
Referenced from: /Users/{username}/opt/anaconda3/lib/python3.9/site-packages/prophet/stan_model/prophet_model.bin
Reason: tried: '/private/var/folders/cd/dfrqgp4s4ll55cwb7rtgccbw0000gq/T/pip-install-rjpuj450/prophet_d7e4cce10e414c89a572fe3605ae9269/build/lib.macosx-11.1-arm64-cpython-39/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbb.dylib' (no such file), '/private/var/folders/cd/dfrqgp4s4ll55cwb7rtgccbw0000gq/T/pip-install-rjpuj450/prophet_d7e4cce10e414c89a572fe3605ae9269/build/lib.macosx-11.1-arm64-cpython-39/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbb.dylib' (no such file), '/usr/local/lib/libtbb.dylib' (no such file), '/usr/lib/libtbb.dylib' (no such file)
I know this has to do with the wrong paths being searched. I can find the dylib in
/Users/{user}/opt/anaconda3/lib/python3.9/site-packages/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/
But, it seems prophet doesn't know to look there. I'm curious how I can update/fix either the rpath variable or find another solution?
I tried to create a symbolic link with sudo ln -s, but don't have permissions on the laptop.
TIA!
I got it to work on Apple Silicon (M1 Max in my case) by installing older versions of both pystan and prophet:
pip install pystan==2.19.1.1
pip install prophet==1.0
The other important piece of the puzzle is that you should use Python 3.8 to get it working.
Installing older versions of the libraries and using Python 3.8 are both talked about in issue #2002 on Github, but there's not really an explanation of the libtbb.dylib error message.

Error: Importing notebooks requires Jupyter nbconvert to be installed. Julia

I am trying to export a Julia Jupyter Notebook to pdf
I installed last version of Julia and VS Code (and the Julia and jupyter extension on VS Code)
I can do fine in jupyter notebooks, the code runs and it's saved on .ipynb format.
So this is what i've done:
In the cmd I just put
py -m pip install jupyter
py -m pip install nbconvert
But whenever I try to export the notebook from VS Code I get this error:
Error 2021-10-19 19:25:11: Export failed [Error: Importing notebooks requires Jupyter nbconvert to be installed.
at u.getExportInterpreter (c:\Users\jparedesm\.vscode\extensions\ms-toolsai.jupyter-2021.9.1101343141\out\client\extension.js:37:319922)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async b.export (c:\Users\jparedesm\.vscode\extensions\ms-toolsai.jupyter-2021.9.1101343141\out\client\extension.js:52:919260)
at async g.export (c:\Users\jparedesm\.vscode\extensions\ms-toolsai.jupyter-2021.9.1101343141\out\client\extension.js:37:290037)
at async l._executeContributedCommand (c:\Users\jparedesm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:94:111644)]
Error 2021-10-19 19:25:11: If you have not installed xelatex (TeX) you will need to do so before you can export to PDF, for further instructions go to https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex.
To avoid installing xelatex (TeX) you might want to try exporting to HTML and using your browsers "Print to PDF" feature.
I do have MikTex installed.
So I don't know what is going on.
Please, let me know how to export a jupyter notebook.
This is what the notebook looks like:
I have a similar problem than yours. The only difference, as I can guess, is that I'm using Mac and have TeXShop instead of MikTex. I have compiled .tex files using xelatex, so I think we both need to tell Visual Studio Code where is the xelatex file. I did a bit of research on the Internet and find suggestions to install the LaTex Workshop extension on VSC. It didn't solve the problem for me, but it'd work for you. I hope so. Let me know in that case.
Best,

Cleanthesis TeX Theme wont create pdf

Im trying to build a (the thesis-example.tex) PDF with the cleanthesis theme (http://cleanthesis.der-ric.de/) and it wont work
The last failure is:
! pdfTeX error (font expansion): auto expansion is only possible with scalable
fonts.
\AtBegShi#Output ...ipout \box \AtBeginShipoutBox
\fi \fi
l.107 \cleardoublepage
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on thesis-example.log.
Im currently on a Fed26 System with 5928 installed texlive packages.
(dnf install texlive-scheme-full, dnf install texlive-*)
If i try this with a complete stock Ubuntu 16.04 and texlive-publisher and texlive-full packages it works. So i guess there is no missing package.
I you need specific parts of thesis-example.log, let me know i cant paste it because its too large
So i installed a clean Fed26 and loaded all texlive packages i had on the main pc. I compared /etc/texlive/web2c/updmap.cfg and i saw that my updmap.cfg was currupted.
I copied the working updmap.cfg to my main system and did a "updmap-sys --force" and now it works

repose.who-friendlyform dependency in TurboGears 2

I am trying to install TurboGear 2. I was following the steps given in this documentation. Link: http://toscawidgets.org/documentation/tw2.core/turbogears.html
On executing this command
pip install -e .
i got this error
No distributions at all found for repose.who-friendlyform>=1.0.4 (from example==0.1dev)
Then with this command
python setup.py develop
i got this error
Searching for repose.who-friendlyform>=1.0.4
Reading https://pypi.python.org/simple/repose.who-friendlyform/
Couldn't find index page for 'repose.who-friendlyform' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
No local packages or download links found for repose.who-friendlyform>=1.0.4
error: Could not find suitable distribution for Requirement.parse('repose.who-friendlyform>=1.0.4')
I tried to install it with easy_install but it didn't work. How can i overcome this error?
The documentation you are pointing to is quite outdated, which TurboGears version are you trying to use? Latest TG versions don't depend on repoze.who-friendlyform anymore. Try to delete your virtualenv, recreate it and then install TurboGears with pip install tg.devtools.
You can find latest TG version documentation on http://turbogears.readthedocs.org/en/latest/#installing-turbogears with a tutorial on using ToscaWidgets at http://turbogears.readthedocs.org/en/latest/cookbook/TwForms.html
Also latest ToscaWidgets documentation has been moved at http://tw2core.readthedocs.org/en/latest/
If you want to experiment with TG2 and Forms there are also a bunch of runnables you can play with: http://runnable.com/TurboGears