update with fix for pip and python3.11 on Ubuntu 22.04 - online edit of handbook/computing/wsllaptop.html

This commit is contained in:
Expo on server 2023-04-26 21:52:00 +01:00
parent 2665bca3a8
commit e310706665

View File

@ -6,6 +6,7 @@
<link rel="stylesheet" type="text/css" href="../../css/main2.css" />
</head>
<body>
<style>body { background: #fff url(/images/style/bg-system.png) repeat-x 0 0 }</style>
<h2 id="tophead">CUCC Expedition Handbook - Computers/WSL</h2>
<h1>WSL on a Windows laptop</h1>
@ -20,8 +21,8 @@
<br>
<a href="winlaptop.html">Setting up a Windows machine for expo bulk data rearrangements</a>
</p>
On 23 November 2022 a new way of installing and using WSL was announced, see <a href="https://www.theregister.com/2022/11/23/wsl_microsoft_store_default_version/">
Windows Subsystem for Linux now packaged as a Microsoft Store app</a> so some of the documentation on this expo site needs to be revised. <a href="https://learn.microsoft.com/en-us/windows/wsl/compare-versions?source=recommendations">WSL2 is now noticeably even slower</a> for NTFS files.
In late 2022 a new way of <a href="https://www.theregister.com/2022/11/23/wsl_microsoft_store_default_version/">
installing and using WSL</a> was announced and this page has been revised to match. <a href="https://learn.microsoft.com/en-us/windows/wsl/compare-versions?source=recommendations">WSL2 is now noticeably even slower</a> for NTFS files, so now it is only really useable if you move all the troggle code into your Linux filespace on <var>\\wsl.localhost\Ubuntu-22.04\home</var> which means that those files will only be accesible from Linux. Buggeration. If you have to use NTFS for those files for some other reason, you would need to revert to using WSL1.
<h3>WSL1 and WSL2</h3>
<p>WSL now installs as WSL2 by default, but older machines (mostly laptops) may not have the Hyper-V Virtualization hardware and may have to run WSL1.
This is fine: the behaviour is nearly identical so far as an expo laptop is concerned, where you just want to use rsync and scp. An old 2011-era PC has
@ -40,9 +41,9 @@ certainly have to move all your code to the internal network share e.g. <var>\\w
is how it looks when you are browing from Windows.
(No, don't try to be cute and keep it on <var>/mnt/c/</var> and just put a soft link in <var>/home/expo/</var>. That doesn't work either.)
This means that the code is actually living on a Linux <var>ext4</var> filesystem hidden away on your disc where you can only see it using the
'network' method <var>\\wsl$\Ubuntu-20.04\home\expo\troggle\</var>. This means that file access is somewhat faster too but you probably won't notice. You will need to make sure that your backup/archive methods access this filesystem though.
'network' method <var>\\wsl$\Ubuntu-20.04\home\expo\troggle\</var>. This means that file access is noticably faster too. You will need to make sure that your backup/archive methods access this filesystem though.
<p>rsync doesn't work with NTFS partitions the way that WSL1 does.
<p>NB rsync doesn't work with NTFS partitions the way that WSL1 does.
<p>Read <a href="https://code.visualstudio.com/blogs/2019/09/03/wsl2">WSL & Visual Studio Code</a> and go back and read the bits about VS Code
running remotely in the &#8251;Windows data maintenance laptop page.
@ -57,10 +58,13 @@ permissions that are fundamentally different things and are never in sync in any
href="https://devblogs.microsoft.com/commandline/chmod-chown-wsl-improvements/">All sorts of fun</a> results. The alternative is to store all your data
in the \\wsl$\ ext4 filesystem (WSL2 only, not WSL1).
<p>If you are disturbed by the instructions to produce an entirely different key for WSL to use when your PC already has a perfectly good PuTTy key installed on the server, then you are right. It is inelegant. But it works, the instructions are shorter and there are fewer things that go wrong. If you are terribly offended by that then you can set your PC up to use one key shared between WSL and normal-Windows as described in <a href="https://devblogs.microsoft.com/commandline/sharing-ssh-keys-between-windows-and-wsl-2/">this October 2019 article</a>. (Don't set up a password on the key because then you don't need to install keychain.) But beware, this sort of thing goes out of date quite rapidly.
<p>If you are disturbed by the instructions to produce an entirely different SSL key for WSL to use when your PC already has a perfectly good PuTTy key installed on the server, then you are right. It is inelegant. But it works, the instructions are shorter and there are fewer things that go wrong. If you are terribly offended by that then you can set your PC up to use one key shared between WSL and normal-Windows as described in <a href="https://devblogs.microsoft.com/commandline/sharing-ssh-keys-between-windows-and-wsl-2/">this October 2019 article</a>. (Don't set up a password on the key because then you don't need to install keychain.) But beware, this sort of thing goes out of date quite rapidly.
<h4>WSL - Creating another ssh key</h4>
<p>If you have PuTTY installed and working, but you now want to use WSL rsync, you need to set up a key again within the WSL environment. So on a machine with WSL enabled, create an ordinary cmd window and get into the WSL environment using the wsl command:<br />
<p>If you have PuTTY installed and working, but you now want to use WSL rsync, you need to set up a key again within the WSL environment.
<p>[ Now that Microsoft allows installation of OpenSSL using <a href="">standard Windows tools</a> on Windows 10 and 11, we need someone to revise all the Windows/troggle documentation for a PuTty-free route. Volunteers? ]
<p> So on a machine with WSL enabled, create an ordinary cmd window and get into the WSL environment using the wsl command:<br />
<span style="font-family:monospace; size=x-small; background-color: lightgray">
D:\CUCC-Expo\expoweb\ <font color=red>wsl</font>
</span>
@ -158,7 +162,19 @@ and <a href="https://www.windowscentral.com/how-install-wsl2-windows-10">here</a
<tt><a href="https://www.scivision.dev/mount-usb-drives-windows-subsystem-for-linux/">mount-usb-drives-windows-subsystem-for-linux</a></tt>
<tt><a href="https://man.openbsd.org/ssh">ssh command line</a></tt>
<h3 id="pain">The pain continues: Python on WSL2 </h3>
<p>WSL2 installs python by default, but it may be a rather old python (depending on the history of your laptop, phase of moon etc.) and if you want development speed you want python3.11. [NB the expo server currently runs python 3.9, so don't use any post3.9 idioms in your code.]
<p>To install python3.11 and pip follow <a href="https://stackoverflow.com/questions/70260339/cant-run-pip-on-python-3-11">these instructions</a> to the letter. But that's not enough, you need to configure pip to work properly with python3.11 (this is because it's a bit bleeding edge as yet), so you ALSO then need to re-install the latest with:
</p>
<code><pre>
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
and test the result using:
python3.11 -m pip --version
</pre></code>
<p>The error you are trying to get rid of when attempting to use pip looks like this:<br />
<var>ImportError: cannot import name 'html5lib' from ...</var>
<hr />
Go back to: &#8251;<a href="basiclaptop.html">Basic laptop</a><br />
Go back to: &#8258;<a href="surveylaptop.html">Survey laptop</a><br />