Re: Jupyter notebooks to A4 (again)
Martin Schöön writes:
> Hello all,
>
> Some years ago I asked about exporting notebooks to pdf in
> A4 rather than US Letter. I got help, rather detailed
> instructions from you in general and Piet von Oostrum in
> particular. Following the advice helped and I was happy.
>
> Now it does not work any longer:
>
> nbconvert failed: A4article
>
> I am stumped. I have not changed anything and all
> looks OK.
>
> Today I tried up-dating all things Python and Jupyter
> but that did not help.
>
> I have also tried removing the A4 stuff and after
> restarting Jupyter I can export to PDF and get US Letter
> paper format.
>
> A quick and (obviously) not very clever internet search
> yielded nothing helpful.
The template system has changed in nbconvert version 6, so the original
templates don't work anymore.
And they still haven't supplied standard provisions for A4 paper (like an
option or so). Probably a mild case of cultural blindness.
I found out how to do it in the new template system, however, there is a bug
that gives some troubles.
To get all your latex (and therefore also PDF) output in A4 format:
Find out where nbconvert expects user templates.
Issue the shell command:
bash-3.2$ jupyter --paths
Look up the data part:
...
data:
/Users/pieter/Library/Jupyter
...
The first one is your personal directory in my case ~/Library/Jupyter.
In this directory create the directory nbconvert/templates/latex
In this directory create these two files:
conf.json
{
"base_template": "latex",
"mimetypes": {
"text/latex": true,
"text/tex": true,
"application/pdf": true
}
}
index.tex.j2
((=- Default to the notebook output style -=))
((*- if not cell_style is defined -*))
((* set cell_style = 'style_jupyter.tex.j2' *))
((*- endif -*))
((=- Inherit from the specified cell style. -=))
((* extends cell_style *))
%===
% Latex Article
%===
((*- block docclass -*))
\documentclass[a4paper,12pt]{article}
((*- endblock docclass -*))
Now jupyter nbconvert --to latex my_nb.ipynb will generate latex with a4paper.
If you don't want this to be the default, but you want a special template,
let's say A4article, to do this, place these files in a directory
.../nbconvert/templates/A4article rather than .../nbconvert/templates/latex.
Then you would use jupyter nbconvert --to latex --template A4article my_nb.ipynb
However, due to a bug this won't work unless you patch the nbconvert export
code.
This is a simple one-line patch.
See
https://github.com/jupyter/nbconvert/pull/1496/commits/a61a2241a87912005720d3412ccd7ef7b5fce6dd
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
Pyautogui troubles
Dear Python-Team, I have just repaired python after running my program which imports pyautogui, closing and reopening it and then getting this: ModuleNotFoundError: No module named „pyautogui“. Repairing didn’t work and I still get that message. All I did was closing the perfectly working program in 3.9.1 and reopening it in 3.9.1, but after the reopen I got the message. I’ve tried looking for solutions in at least seven developer forums, nothing worked. If it helps, I have Python 3.8 installed on my PC also. I hope you can fix my troubles. Thank you in advance, your help seeker. -- https://mail.python.org/mailman/listinfo/python-list
Re: Pyautogui troubles
On 1/30/21 2:58 PM, Philipp Daher via Python-list wrote: > Dear Python-Team, > > I have just repaired python after running my program which imports pyautogui, > closing and reopening it and then getting this: ModuleNotFoundError: No > module named „pyautogui“. Repairing didn’t work and I still get that message. > All I did was closing the perfectly working program in 3.9.1 and reopening it > in 3.9.1, but after the reopen I got the message. I’ve tried looking for > solutions in at least seven developer forums, nothing worked. If it helps, I > have Python 3.8 installed on my PC also. > > I hope you can fix my troubles. I've never heard of pyautogui. It's not something that ships with Python if I'm not mistaken. Is this something you installed? Note that just because you installed a module under 3.8 does not mean it will automatically be available in 3.9.1. You'll probably have to install it using 3.9.1's pip. -- https://mail.python.org/mailman/listinfo/python-list
Re: Pyautogui troubles
On 1/30/21 2:58 PM, Philipp Daher via Python-list wrote:
Dear Python-Team,
I have just repaired python after running my program which imports pyautogui,
closing and reopening it and then getting this: ModuleNotFoundError: No module
named „pyautogui“. Repairing didn’t work and I still get that message. All I
did was closing the perfectly working program in 3.9.1 and reopening it in
3.9.1, but after the reopen I got the message. I’ve tried looking for solutions
in at least seven developer forums, nothing worked. If it helps, I have Python
3.8 installed on my PC also.
I hope you can fix my troubles.
We can't fix it, but maybe point you to some things to let you fix it :)
Sorry if you've already seen this.
Remember: a missing module is a path problem. The module is either
someplace, or it isn't ("not actually installed" happens often, but
apparently isn't your case since things worked previously). And your
Python isn't looking in the place the module is (or isn't).
Find where the module is installed.
Ask Python where it's looking. Here's a sample interactive session:
$ python
Python 3.8.7 (default, Dec 22 2020, 00:00:00)
[GCC 10.2.1 20201125 (Red Hat 10.2.1-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib64/python38.zip', '/usr/lib64/python3.8',
'/usr/lib64/python3.8/lib-dynload',
'/home/mats/.local/lib/python3.8/site-packages',
'/usr/lib64/python3.8/site-packages', '/usr/lib/python3.8/site-packages']
This article might be a starting point (it's not actually a great
article IMO, but it's referenced from several places on the net and it
does cover a lot of the topics):
https://coderslegacy.com/python-no-module-named-import-error/
--
https://mail.python.org/mailman/listinfo/python-list
Re: Converting hex data to image
[email protected] در تاریخ سهشنبه ۱۲ مارس ۲۰۱۹ ساعت ۱۳:۰۱:۴۵ (UTC+3:30) نوشت: > On Tuesday, March 12, 2019 at 2:53:49 PM UTC+5:30, Peter Otten wrote: > > [email protected] wrote: > > > > >> Save the image to a file (in binary mode!) and then try to open it with > > >> an image viewer. The data may be corrupted. > > > > > > When i tried doing that it says Invalid Image... > > > > So it looks like the problem occurs somewhere before you are decoding the > > image with the PIL... > This is what i am doing : > for associate in self.conn.response[:-1]: > attributes = associate['attributes'] > obj = { > 'img':attributes['thumbnailPhoto'],} > This img i am calling in my view and writing to the file... Hi could you solve this problem dimplem? I have exactly the same issue when I read thumbnailPhoto from active directory -- https://mail.python.org/mailman/listinfo/python-list
