- Windows 10 64 bit
- Python 3.x 64 bit or errors will occour when installing pywinpty
- MS Visual Studio Build Tools (for c++ compiler)
- Set Python and Python/Scripts paths to system path (reboot required).
- pip install pywinpty
- pip install notebook
- pip install jupyterlab
Jupyter automatically starts with local languages, to stick with English:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
or on Windows CMD:
set LC_ALL=en_US.UTF-8
set LANG=en_US.UTF-8
If you are running Python 32 bit versions, errors will occor:
pip install pywinpty
error running the above command
Cannot open include file: 'winpty.h': No such file or directory error
anwser: https://www.kannon.link/free/2018/09/19/installing-jupyter-on-python-3-7-on-windows/
down load and unzip one of the binary releases of winpty from winpty 0.4.3.
copy the following files to the appropriate folders, which your paths include.
- include/winpty.h, winpty_constants.h
- x64/lib/winpty.lib
- x64/bin/winpty.dll
- retry "pip install jupyter".
anwser: andfoy/pywinpty#123
Jupyter use the LaTeX engine, XeLaTeX to be specifc, and Pandoc to generate PDF format, so correct configurations for XeLaTeX and MiKTeX is important.
Reference
- Install Pandoc.
- Install XeLaTeX(already installed with basic features after Jupyter installation).
- Install MiKTeX.
Use the command line to generate PDF format first to make sure everything is okay.
Generate a latex file from your Jupyter notebook file.
jupyter nbconvert --to latex yourfile.ipynb
return: yourfile.tex
Convert it PDF with XeLaTeX
xelatex youfile.tex
There are about over 100 packages that XeLaTeX would automatically install, just wait till it finish. The "file too old" error might occur, just type "R" to continue without it.
Run MiKTeX console as a Administrator or sudo
, press "check for update", wait till it finish.
In order to display Chinese properly, you need to add some codes to the file base.tplx
which is a package of XeLaTeX:
- Get the site-package directory of Python:
import site
site.getsitepackages()
- Go to that directory
cd %python-site-package-directory%/nbconvert/templages/latex
nano base.tplx
find ((* block packages *))
, then add the following codes:
\usepackage{fontspec, xunicode, xltxtra}
\setmainfont{Microsoft YaHei}
\usepackage{ctex}
note that there're four spaces for the indent, not tabs.
And now run jupyter nbconvert --to pdf yourfile.ipynb
and it should be fine.