PyData stack in your pocket.
Gaiar BaimuratovBlockedUnblockFollowFollowingMay 13On running Jupyter Notebooks on your phoneI’ve recently upgraded my classy iPhone SE to Samsung Note 9 and among the reasons like an amazing camera and huge screen was “It can run Ubuntu”.
Kind of geeky reason, I know.
But yes, it really can run Ubuntu via a containerization layer called “Linux on Dex”.
It is an app which allows you running pure Ubuntu 16.
04 desktop for the ARM64 architecture.
What you need are just any good-quality USB-C HDMI adapter, Bluetooth keyboard/mouse set (or just USB ones if you are using USB-C hub) and a spare screen.
To try Linux on Dex you just need a USB-C screen cable, as a phone can act a touchpad and keyboard.
That is how it looks.
I’ve used my wife's Apple USB-C adapter to connect screen and keyboard.
But why?!One of my hobbies is trying to run Python on different weird devices like Raspberry Pi, VoCore and Lichee Pi NanoWhy not spend your weekend bringing upstream Linux on some cheap SBC or running Ubuntu with Anaconda on Android Tablet?The ability of these small cheap devices to run regular Linux with Python amazes me, as still remember booting my 486DX2 66Mhz.
If these tiny things can run regular Python, then it is definitely worth trying to the same with the 8 Core CPU/6GB RAM beast (yes, I have a “cheap” version, not the one with 8GB).
From my experience of dealing ARM-based Python distributions, the road wouldn’t be straight, but it doesn’t mean that it doesn’t worth trying.
And I’ve already contributed to building ARM conda packages for Raspberry Pi, so most of the steps I was aware of.
Get Linux on Dex appTo get Linux on Dex application you’ll to have to sign up for Beta program.
You can do it here:Sign in – Google AccountsEdit descriptionplay.
comMore information on supported phones and features, get on the website:https://www.
com/Install and Run the containerDownload an image after app installation and unzip the file.
Then create a container and launch itCreate a nice recognizable name for your container.
It will help you later.
It will take some time to download and unzip the image, so be patient.
If there are problems with download, try direct link.
Fix apt package managerUnfortunately, Ubuntu in “Linux on Dex” comes half-baked with broken aptitude manager.
But luckily community figured out a way how to fix it.
Run the following set of commands in Terminal.
It could happen that in a process of apt-get upgrade you’ll have to kill the hang process by pressing “Ctrl+C” several times.
sudo apt-get updatesudo apt-get upgradesudo purge-old-kernelssudo apt auto removesudo apt autocleanInstall dependenciesArchiconda was initially built to support newer version of Ubuntu, so Python needs fresher libc library and other dependencies.
We’ll grab it from Ubuntu 18.
04 ARM64 distribution.
deb -O libc6_2.
deb -O libc-bin_2.
debsudo dpkg -i libc6_2.
debsudo dpkg -i libc-bin_2.
deb -O locales_2.
debsudo dpkg -i locales_2.
deb -O zlib1g-dbg_1.
deb -O zlib1g-dev_1.
debsudo dpkg -i zlib1g-dbg_1.
debsudo dpkg -i zlib1g-dev_1.
debCreate a conda userDue to some problems on permissions management for the default dextop user, conda package manager can’t write in its own folder.
Of course, its something that can be fixed, but easier to create dedicated conda user and manage environment using it.
Create a user by adduser condauser and then add that user to sudoers by running sudo usermod -aG sudo condauser .
The default root password for Linux on Dex is secret.
Provide permissionsFew more fixes needed (a common story with beta software).
If you now try to ping any remote host, you’ll that you don’t have network permissions.
Somehow freshly create users under “Linux on Dex” are not assigned for “network” group.
To fix that, you need to edit etcgroup file and fix groups inet and net_raw by adding condauser as followinginet:x:3003:root, condauser, dextopnet_raw:x:3004:root, dextop, condauserNow you can change your current user to condauser by running su — condauserInstall ArchicondaDownload and install ArchiConda.
We are using not the latest version because we need some packages from the archiarm channel, which missing from 0.
shchmod +x Archiconda3-0.
shNow let’s add update conda by runningconda update -n base –alland add my channel containing missing packages like Jupyter Notebookconda config — add channel gaiarconda install -c gaiar jupyterInstall other packagesAs jupyter is installed and conda has access to the channels containing aarch64 package distributions, we can install any required packages the way you got used to, as for exampleconda install seaborn -yRunning Jupyter on your phoneNow are all set for running Jupyter on your phone, so let’s run Jupyter Notebookjupyter notebook If everything went fine with previous steps you will see something likeJupyter notebook server running on Note 9Download notebookFor testing clone repo with Seaborn examples https://github.
com/PatWalters/plotting_distributionsLaunch notebook and run all cells.
Then you see something like thatSeaborn with Jupyter Notebook running finePokedex (some fun)If you are getting bored, then you can even run jupyter notebook server on your phone and connect via laptop.
For that you need to start “Linux on Dex” in “Terminal mode”.
And then real fun starts.
Try typing all commands mentioned previously on phone keyboard.
Luckily, Note 9 quite bigTo run notebook in headless mode, you’ll need to change few commands.
First, make sure you are connected to the WiFi network and get your local IP.
For that run ip a and search for wlan0 .
Remember and copy the address.
Then run Jupyter notebook with the commandjupyter notebook –ip YOU_IP –NotebookApp.
Get your IP address.
Start Jupyter Notebook.
See progressIf you did everything correctly, then you’ll be able to run browser on another computer from the same network and access your “server” with the URL likehttp://YOUR_IP:8888 .
Enter your token and enjoy :)Access notebook running our the phoneP.
Most of current article was written directly on the phoneWho does need laptops these days?.