Software Installs and Environment Setup
General Tips
Getting your software and programming tools working correctly can be tedious and annoying, but it’s an important part of the life of a data scientist.
Before you get started in any new install, make sure you have time to complete it. That means having plenty of battery (or an outlet available), a fast internet connection, and nowhere else to be for the next hour.
You should already have most of the software below installed from previous classes; come back here and re-install if your laptop gets wiped by ITSD or something stops working.
SD212 directory
This is the directory where you should do your work for the class. We will use it to share files that you will need to get started on various assignments, and to help make sure you have the right packages installed.
You must run these commands to download and set up your sd212 folder on a lab machine or over ssh:
cd
git clone https://github.com/sd212usna/sd212-folder sd212
sd212/setup.sh
After this initial setup, close VS code (if you have it open),
then open VS code and open this new sd212 directory in VS code.
You should be all set!
If you want to also have this set up on your laptop locally using WSL, then just run those three commands in a WSL terminal on your laptop.
WSL/Ubuntu
- Laptop only (already on the lab machines)
- Should be fine from SD211 except the part below about
creating your
sd212directory
Installation
This should be fine from SD211; it is the same as Step 1 in the SD211 setup instructions.
Open a powershell as Windows administrator: hit WindowsKey+R to bring up the run dialog, type
powershell, then hit Ctrl+Shift+Enter to run as administrator.Run this command in the powershell:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-LinuxRestart Windows
Open Software Center and install “Ubuntu 20.04 LTS”
After the install completes, open Ubuntu for the first time. You will be prompted to choose a username and password.
You must choose your USNA username
m2XXXXXas the username.Use any simple password. It doesn’t need to be (and probably shouldn’t be) the same as your USNA password, and is only used to install software and other stuff inside Ubuntu on your laptop, so security isn’t a huge concern here. Keep it simple and memorable.
Forgot Ubuntu WSL password
If you forget your (simple, non-USNA) WSL Ubuntu password at some point, it’s easy to reset it.
Just follow the instructions on this StackOverflow post,
where in the first step you are opening cmd.exe from the Windows taskbar,
and in the third step you use your own username like m261234.
Fix WSL networking settings
Before you start doing anything in your fresh Ubuntu WSL installation, you need to fix the DNS and certificate settings so that it will work on the USNA network.
First make sure you are actually connected to the USNA mission network. Then run this command which downloads and executes a bash script to fix things up all nice-like:
curl -s http://faculty.cs.usna.edu/~roche/fix-wsl.sh --resolve 'faculty.cs.usna.edu:80:10.1.83.71' | bash
Software update
The software inside WSL/Ubuntu is not updated automatically by ITSD/Windows like everything else on your laptop. You should do this update periodically, at the very least at the start of the semester is a good time.
First, open an Ubuntu terminal from the start menu. Then run these two commands, in order. When asked, enter your simple Ubuntu password.
sudo apt update
sudo apt full-upgrade
SSH keys
(Should already be done from SD211.)
Setting up SSH keys makes it so that you can easily access the CS department server and lab machines through SSH without having to type your password every time.
Run these commands from an Ubuntu terminal window. On the third step, you may be prompted for a password. That should be your USNA password, not your Ubuntu password.
mkdir -p ~/.ssh
[[ -e ~/.ssh/id_ed25519 ]] || ssh-keygen -t ed25519 -N ''
ssh-copy-id "$USER"@ssh.cs.usna.edu
cp ~/.ssh/id_ed* /mnt/c/Users/`whoami`/.ssh/
Xming
(Should already be done from SD211)
Xming is a small Windows utility that let’s you display GUIs from WSL or ssh.
Install
- Visit https://sourceforge.net/projects/xming/
- Download Xming
- Run as administrator the file you just downloaded
Running/restarting
Xming should be running all the time on your laptop, before you open VS Code for example. If Xming is running, you will see its little X icon in the system tray on the bottom-right of the start menu.
If not, then maybe Xming got closed or crashed for some reason. You should be able to find the Xming program in the start menu and just click it to start it up again.
VS Code
(This should be already done from SD211; see step 3 in these instructions.)
Installation
- Go to https://code.visualstudio.com/ and download for Windows.
- Run the installer after it downloads.
Setup WSL
- Open VSCode
- Open the “Extensions” pane (icon with 4 squares on the left side)
- Search for and install the “Remote Development” extension from Microsoft.
- After that install completes, click the green icon at the very bottom-left
and select “New WSL Window”. It should now say “WSL: Ubuntu 20.04” at the bottom left.
- Now open “Extensions” again. Install the Python and Jupyter extensions from Microsoft.
Setup ssh connection to ssh.cs.usna.edu
Close VS Code and open a Powershell in Windows.
Run this command from Powershell:
setx DISPLAY "127.0.0.1:0.0"
Close Powershell and start VS Code again.
Open the Remote Explorer (it’s the computery icon on the left side of the window)
In the remote explorer, click the little + sign next to SSH to add a new SSH
remote host. In the box that pops up, type
ssh m2XXXXX@ssh.cs.usna.edu -XY
Now you should be able to connect to ssh.cs.usna.edu from the remote explorer.
When you are connected, a whole new VS Code window will come up and it will say
“SSH:ssh.cs.usna.edu” in green on the bottom-right.
After you are ssh’d to ssh.cs.usna.edu, you have to install the VS Code extensions for
Python and Jupyter again.
To go back to your local laptop’s WSL (not SSH), just click the green icon on
the bottom-left and select WSL again.
- Open VSCode
- Open the “Extensions” pane (icon with 4 squares on the left side)
- Search for and install the “Remote Development” extension from Microsoft.
- After that install completes, click the green icon at the very bottom-left and select “New WSL Window”. It should now say “WSL: Ubuntu 20.04” at the bottom left.
- Now open “Extensions” again. Install the Python and Jupyter extensions from Microsoft.
Setup ssh connection to ssh.cs.usna.edu
Close VS Code and open a Powershell in Windows.
Run this command from Powershell:
setx DISPLAY "127.0.0.1:0.0"
Close Powershell and start VS Code again.
Open the Remote Explorer (it’s the computery icon on the left side of the window)
In the remote explorer, click the little + sign next to SSH to add a new SSH
remote host. In the box that pops up, type
ssh m2XXXXX@ssh.cs.usna.edu -XY
Now you should be able to connect to ssh.cs.usna.edu from the remote explorer.
When you are connected, a whole new VS Code window will come up and it will say
“SSH:ssh.cs.usna.edu” in green on the bottom-right.
After you are ssh’d to ssh.cs.usna.edu, you have to install the VS Code extensions for
Python and Jupyter again.
To go back to your local laptop’s WSL (not SSH), just click the green icon on
the bottom-left and select WSL again.
Close VS Code and open a Powershell in Windows. Run this command from Powershell:
setx DISPLAY "127.0.0.1:0.0"Close Powershell and start VS Code again.
Open the Remote Explorer (it’s the computery icon on the left side of the window)
In the remote explorer, click the little + sign next to SSH to add a new SSH remote host. In the box that pops up, type
ssh m2XXXXX@ssh.cs.usna.edu -XYNow you should be able to connect to ssh.cs.usna.edu from the remote explorer.
When you are connected, a whole new VS Code window will come up and it will say
“SSH:ssh.cs.usna.edu” in green on the bottom-right.
After you are ssh’d to ssh.cs.usna.edu, you have to install the VS Code extensions for Python and Jupyter again.
To go back to your local laptop’s WSL (not SSH), just click the green icon on the bottom-left and select WSL again.