Mounting USB drives in Windows Subsystem for Linux

Windows Subsystem for Linux can use (mount):

  • SD card
  • USB drives
  • CD drives (CDFS)
  • Network drives
  • UNC paths

Local storage / drives

Drives formatted as FAT, ExFAT or NTFS can be mounted in WSL. For this example, we assume the drive shows in Windows as F:\ If Windows changes the USB drive letter on a subsequent session, you need to repeat this process.

The commands are typed into the Windows Subsystem for Linux Terminal.

  1. Create a mount location in WSL:

    mkdir /mnt/f
  2. Mount the drive in WSL:

    mount -t drvfs f: /mnt/f

After this one-time setup, one can create and manipulate files from both Windows and WSL on the same drive.

network storage

Here we assume:

  • networked storage is already showing in Windows under \\server\share
  • we want to access this network storage from WSL as /mnt/share
  1. create a mount location in WSL:

    mkdir /mnt/share
  2. mount the network share in WSL:

    mount -t drvfs '\\server\share' /mnt/share

Notes

I did not check:

  • USB floppy drive
  • DVD/Blu-Ray

Add missing LaTeX fonts

Missing LaTeX fonts can be added via TexLive or MikTeX. Using the symbolic fonts is as easy as:

\documentclass[a4paper,12pt]{article}

\usepackage{fontawesome5}

\faGithub This is a GitHub logo.

You may need to use XeLaTeX in some cases.

Note that in LaTeX we use fontawesome5 instead of obsolete fontawesome, which is old version 4. FontAwesome5 is in TeXLive 2018, which on Ubuntu requires Ubuntu ≥ 18.10 or use a PPA.

Linux

Many Linux systems use TeXLive. Here’s how to get a couple popular symbolic fonts (logos for email, phone, GitHub, etc.)

  • marvosym

    apt install texlive-fonts-recommended
  • fontawesome5 (for popular emoji and website icons):

    apt install texlive-fonts-extra

Windows

Many Windows LaTeX users use MikTeX. Use MiKTeX to search for package name and Install:

Start → MiKTeX → Package Manager (admin)

Installing LaTeX editor in Windows

Related: install LaTeX editor on Linux


There are two ways to use TeXstudio LaTeX GUI in Windows:

  • Native Windows
  • Windows Subsystem for Linux.

Windows Subsystem for Linux

Graphical LaTeX editing on Windows can be done via WSL by:

  1. install WSL X11
  2. install TeXstudio for Linux in WSL.

native Windows

  1. Download MiKTeX
  2. Install MikTeX. The default options are generally fine.
  3. Download/Install TeXstudio

Notes

all the references are ??

you need to (re)compile your .bib file by pressing F8 in TeXstudio. Watch for error messages.

MiKTeX install package

This popup occurs when compiling a new document with packages it uses that you don’t have yet. You can uncheck “ask me each time” if you are comfortable with that and want to stop seeing the popups.

Fix “package not found”

  1. press the Windows key then type Package Manger and click on the MiKTeX icon to open the package manager.
  2. click Repository/Synchronize.
  3. install the missing package.

Prolific driver version on Windows

Some older Prolific-based USB interfaces–such as used to program two-way radios and amateur radios–can fail to be recognized on Windows upon first plugin. Looking in Windows Device Manager, the device shows up with a yellow caution sign, and an error message like:

This device cannot start. (Code 10) {Not Enough Quota} Not enough virtual memory or paging file quota is available to complete the specified operation.

Usually the fix is to install an older version of the Prolific driver that is less sensitive to Prolific chip version. We have experienced that the Prolific 3.6 - 3.8 drivers are subject to this issue.

We can’t vouch for the older Prolific 3.2 drivers available but they do work.

Easy install PyPy3

PyPy allows running Python code up to multiple times faster. PyPy is particularly suited for heavy “pure Python” workloads. PyPy does not significantly help for workloads heavy in Numpy array operations, for example. PyPy is slower to start, so if a program isn’t “big enough”, PyPy can be slower than standard CPython. PyPy is available for Linux, MacOS and Windows.

  1. download and extract PyPy3 for your operating system.
  2. add the pypy3 directory containing the PyPy3 executable to your PATH and reopen Terminal / Command Prompt
  3. Install/upgrade Pip so that you can install other packages:

    pypy3 -m ensurepip
    
    pypy3 -m pip install --upgrade pip setuptools wheel
  4. Many PyPi packages can be installed with pip as usual. Note that on Windows, the appropriate version of Microsoft Visual Studio may be required to compile packages from source.

    pypy3 -m pip install numpy

Some packages don’t work yet easily, particularly on Windows, where the compilers and prerequisite libraries may need to be manually built.

Lossless convert PNG image stack to PDF

Converting an image to a PDF file with ImageMagick can be as simple as:

convert in.png out.pdf

For single images -page letter can leave big margins, which may not be desirable.

convert image stack to PDF

This ImageMagick command puts one PNG image per page

convert -page letter -adjoin *.png joined.pdf
-page letter
does not upsize images, so tiny images will be tiny on the page, one image per page.

Print PDF from any Linux program

Related: convert image stack to PDF


On Linux, the CUPS PDF program saves printed PDFs to the ~/PDF directory from any program.

apt install cups-pdf

The output directory can be configured by editing the “Out” directory in /etc/cups/cups-pdf.conf

However, many times we print from Matlab, GNU Octave or Matplotlib using the APIs built-in as described below.

Matlab / GNU Octave

Example to save figure to PDF: this will create a color PDF test.pdf in your current directory from Matlab or Octave.

imagesc(rand(10))

print(gcf, '-dpdf', 'test.pdf')

or

imagesc(rand(10))

saveas(gcf, 'test.pdf')

Comparing print() vs. saveas():

  • print() allows controlling image DPI via the -rDPI option, while saveas() is fixed at 150 DPI
  • saveas() is an “easier” version of print(), since saveas() is actually making calls to print() for both Matlab and Octave.

Matplotlib

This can be accomplished by either

  • save to PDF from the Matplotlib figure GUI
  • use figure.savefig() to save to PDF from Matplotlib.

For situations where local display of figures is not desired, that is, you wish to save figures to disk without displaying them onscreen first, which is generally significantly faster, first do:

import matplotlib
matplotlib.use('Agg')

... (plotting commands)

The Agg Matplotlib backend is commonly used in web/cloud services.

Example:

from matplotlib.pyplot import figure

fg = figure()
ax = fg.gca()
ax.plot(range(10))

fg.savefig('line.pdf',bbox_inches='tight',dpi=300)

Fix Python 3 on Windows error Microsoft Visual C++ 14.0 is required

Related: Fix Python 2 error Visual C++ 10.0 missing vcvarsall.bat


Fix the error for Python 3.6, 3.7 and 3.8 on Windows:

error Microsoft Visual C++ 14.0 is required

as follows. Visual Studio Studio 2019 Build Tools requires about 3 GB of disk space.

  1. Install using any ONE of these choices:
  2. Select: Workloads → C++ build tools.
  3. Install options: select only the “Windows 10 SDK” (assuming the computer is Windows 10). Optionally, if you want to use MSVC cl.exe C/C++ compiler from the command line, additionally select the MSVC 2019 C++ build tools, which takes an additional 1.5 GB disk space. If you need VS2017 C++ Build Tools, this is another 2.5 GB disk space.

Notes

Python versionVisual Studio
2.7, 3.42010
3.52015 / 2017
3.6, 3.7, 3.82017 / 2019

Why Visual C++?

Windows Python needs Visual C++ libraries installed via the SDK to build code, such as via setuptools.extension.Extension or numpy.distutils.core.Extension. For example, building f2py modules in Windows with Python requires Visual C++ SDK as installed above. On Linux and Mac, the C++ libraries are installed with the compiler.

Reference

This was the former link to Microsoft Visual C++ Build Tools–no longer active: https://landinghub.visualstudio.com/visual-cpp-build-tools

Travis-CI default Ubuntu version

Travis-CI switches to default Ubuntu 16.04 as of April 23, 2019. This change was long overdue, but at least didn’t take as long as their default switch to Ubuntu 14.04 from 12.04, which was almost scandalous in how long it took. Travis-CI has many strengths, but one of its weaknesses is their out of date Ubuntu configurations. We have been doing some tasks in AppVeyor alone for some time, since Ubuntu 18.04 has been available on AppVeyor image: ubuntu1804 since September 2018.

Also keep in mind that Travis-CI defaults to Python 3.6 for lang: python builds since April 16, 2019.