This the multi-page printable view of this section. Click here to print.
REU Tutorials
- 1: Installing PyCharm Professional for Free
- 2: Installing Git Bash on Windows 10
- 3: Using Raw Images in GitHub and Hugo in Compatible Fashion
- 4: Using Raw Images in GitHub and Hugo in Compatible Fashion
- 5: Uploading Files to Google Colab
- 6: Adding SSH Keys for a GitHub Repository
- 7: Installing Python
- 8: Installing Visual Studio Code
1 - Installing PyCharm Professional for Free
Abstract
This tutorial teaches how to get PyCharm Professional for free on Windows 10 using a university email address. You can follow a similar process on Linux and macOS.
Contents
Keywords: pycharm
Steps
Click the following image to be redirected to a YouTube video tutorial for installing PyCharm Professional.
Please ensure that you qualify. This includes you having a valid educational email or be part of an open-source project. Make sure to explore the license agreements for PyCharm as they may change.
-
Open up a web browser and search
pycharm
. Look under the link fromjetbrains.com
and clickDownload PyCharm
. -
Click the blue button that reads
Download
under Professional. Wait for the download to complete. -
Open the completely downloaded file and click
Yes
on the UAC prompt.- If you have a school computer, please refer to the note under step 5 of the Windows section in the Python tutorial found here: https://github.com/cybertraining-dsc/cybertraining-dsc.github.io/blob/main/content/en/docs/tutorial/reu/python/index.md
-
Click
Next
, clickNext
again, and check the box that readsAdd launchers dir to the PATH
. You can also create a Desktop Shortcut and create the.py
association if you would like. The association changes which program, by default, opens.py
files on your computer. -
Click
Next
and then clickInstall
. Wait for the green progress bar to complete. Then, you must restart your computer after making sure all of your programs are saved and closed. -
Open PyCharm either by clicking on the Desktop shortcut you might have made or hit the Windows key and type
PyCharm
and choose the program from the search results. -
Check the box that says
I confirm that I have read and accept the terms...
after agreeing to the terms. -
Click
Continue
. You can choose to send anonymous statistics, if you want to; click the option you want. -
Click the hyperlink that says
Buy license
in the top right of the window. Do not worry — you will not be spending a cent. -
Click the person icon in the top right of the page (if you cannot find this person icon, then click this link and hopefully, it still works: https://account.jetbrains.com/login ).
-
Create a JetBrains account by entering your university email address. Click
Sign Up
after entering your email; then, you have to go on your email and confirm your account in the automated email sent to you. ClickConfirm your account
in the email. -
Complete the registration form and click
Submit
. -
Click
Apply for a free student or teacher license
. Scroll down and click the blue button that readsApply now
. -
Fill out the form using your (educational) email address and real name. Check the boxes if they apply to you. Then click
APPLY FOR FREE PRODUCTS
. -
JetBrains should send you an automated email, ideally informing you that your information has been confirmed and you have been granted a free license. If it does not arrive immediately, wait a few minutes. Go back to PyCharm and sign in with your JetBrains account after receiving this email. Click
Activate
. Now you can use PyCharm.
2 - Installing Git Bash on Windows 10
Abstract
This tutorial teaches how to install Git and Git Bash.
Contents
Keywords: git
Windows
Click the following image to be redirected to a YouTube video tutorial for installing Git and Git Bash. This same video also includes instructions to create a virtual Python environment, which you can do as well.
To verify whether you have Git, you can press Win + R
on your desktop, type cmd
, and press Enter
. Then type git clone
and press Enter
. If you do not have Git installed, it will say 'git' is not recognized as an internal or external command...
As long as Git does not change up their website and hyperlinks, you should be able to download Git from here and skip to step 2: https://git-scm.com/downloads
-
Open a web browser and search
git
. Look for the result that is fromgit-scm.com
and click Downloads. -
Click
Download for Windows
. The download will commence. Please open the file once it is finished downloading. -
The UAC Prompt will appear. Click
Yes
because Git is a safe program. It will show you Git’s license: a GNU General Public License. ClickNext
.- The GNU General Public License means that the program is open-source (free of charge).
-
Click
Next
to confirm thatC:\Program Files\Git
is the directory where you want Git to be installed. -
Click
Next
unless you would like an icon for Git on the desktop (in which case you can check the box and then clickNext
). -
You will be asked several questions for the setup. We recommend the following settings:
- Click
Next
to accept the text editor, - Click
Next
again to Let Git decide the default branch name - Click
Next
again to run Git from the command line and 3rd party software, - Click
Next
again to use the OpenSSL library - Click
Next
again to checkout Windows-style, - Click
Next
again to use MinTTY, - Click
Next
again to use the default git pull, - Click
Next
again to use the Git Credential Manager Core, - Click
Next
again to enable file system caching, and then - Click
Install
because we do not need experimental features.
- Click
-
The progress bar should not take too long to finish. To test if it is installed, you can search for
Git Bash
in the Windows search now to run it.
3 - Using Raw Images in GitHub and Hugo in Compatible Fashion
This tutorial teaches how to add images on GitHub and use them in your markdown file that can be rendered in Hugo and markdownon GitHub.
Contents
Keywords: github
Steps
-
Upload your image to GitHub in the images directory
-
Click on the image file and then right click on it and click
Open image in new tab
-
Use the URL shown in the address bar of the new tab to paste into the markdown file.
-
When using the file, please add a caption; also, if it is copied, make the citation which should point to the reference section
![database sample](https://github.com/cybertraining-dsc/cybertraining-dsc.github.io/raw/main/content/en/docs/tutorial/reu/github/images/images-download.png)
**Figure 2:** Sample Database file obtained from the USGS
water-quality database for the year 2017 [^1]
## Refernces
[^1]: HERE COMES THE CITATION OF THE IMAGE
4 - Using Raw Images in GitHub and Hugo in Compatible Fashion
This tutorial teaches how to add images on GitHub and use them in your markdown file that can be rendered in Hugo and markdownon GitHub.
Contents
Keywords: github
How to use images is clearly shown in our template at
https://github.com/cybertraining-dsc/hid-example/blob/main/project/index.md
5 - Uploading Files to Google Colab
Abstract
This tutorial teaches how to import CSV’s into a Google Colab .ipynb.
Contents
Keywords: colab
Note
There are two different methods of uploading files to Google Colab Jupyter notebooks. One way is to have the user upload the file to the user’s Google Drive before running the notebook. Another way is to have the notebook ask the user to upload a file directly into the notebook from the user’s computer. This tutorial outlines both ways.
The notebook code with both methods can be found here
Read File from Drive
This code will read a CSV file using pandas. Before running it, the user
must upload the CSV file to the Google Drive of the same Google account on which it runs the notebook in Colab (e.g., your account). The
CSV file in this example is titled kag_risk_factors_cervical_cancer
but please rename it accordingly to match the file
you would like to upload.
Cell 1:
import pandas as pd
from google.colab import drive
drive.mount("/content/gdrive", force_remount=True)
# The next line of code will tell Colab to read kag_risk_factors_cervical_cancer.csv in your Drive (not in any subfolders)
# so you should alter the code to match whichever .csv you would like to upload.
df=pd.read_csv('gdrive/My Drive/kag_risk_factors_cervical_cancer.csv')
# The next two lines of code convert question marks to NaN and converts values to numeric type, consider
# removing the next two lines if not necessary.
df = df.replace('?', np.nan)
df=df.apply(pd.to_numeric)
# If this cell successfully runs then it should output the first five rows, as requested in the next line of code
df.head(5)
Colab will ask you to click on a blue link and sign in with your account. Once done, the user must copy a code
and paste it into the box on Colab for authentication purposes. Press Enter
after pasting it into the box.
If it outputs an error along the lines of unknown directory
, try rerunning the two cells and ensuring that
your CSV is not in any folders inside Google drive. You can also alter the code to point it to a subdirectory if needed.
Read File from Direct Upload
To read it with built-in Colab methods, you can use the following code:
Cell 1:
from google.colab import files
df = files.upload()
The user will be prompted to click Browse...
and to find the file on the user’s local
computer to upload. Sometimes trying to upload the file will give this error:
MessageError: RangeError: Maximum call stack size exceeded.
In this case, the user should click the folder icon on the left side of Google Colab window, then the paper with an arrow icon (to upload a file), then upload the CSV you wish to use. Then rerunning Cell 1 is not necessary. Simply proceed to Cell 2. If this still does not work, see this stackoverflow page for further information.
Cell 2:
df=pd.read_csv('kag_risk_factors_cervical_cancer.csv')
# The next two lines of code convert question marks to NaN and converts values to numeric type, consider
# removing the next two lines if not necessary.
df = df.replace('?', np.nan)
df=df.apply(pd.to_numeric)
# If this cell successfully runs then it should output the first five rows, as requested in the next line of code
df.head(5)
Remember to rename the instances of kag_risk_factors_cervical_cancer.csv
accordingly so that it matches your file name.
Acknowledgments
Credit to Carlos who provided the cell to upload the file directly.
6 - Adding SSH Keys for a GitHub Repository
This tutorial teaches how to configure an SSH Key on GitHub so that you can clone, commit, pull, and push to repositories (repos).
Contents
Keywords: ssh
Windows
Please ensure that you have Git (Git Bash) and a repository on GitHub. This tutorial was created with the REU program in mind, where the students are provided with a GitHub repository. If you are not in REU, then you can create a new repository on GitHub and clone that instead.
-
Open Git Bash by pressing the Windows key, typing
git bash
, and pressing Enter. -
Then, go on GitHub, click on your profile icon in the top right, click
Settings
, and clickSSH and GPG keys
on the left hand side. Confirm that there are no SSH keys associated with your account. If there are keys, then perhaps you have made some already. This tutorial focuses on creating a new one. -
Go back to Git Bash and type
ssh-keygen
. PressEnter
. PressEnter
again when it asks you the file in which to save the key (it should sayEnter file in which to save the key (/c/Users/USERNAME/.ssh/id_rsa):
.- If you have already created a key here, it will ask you if you would like to overwrite the file. Type
y
and pressEnter
.
- If you have already created a key here, it will ask you if you would like to overwrite the file. Type
-
Enter a password that you will remember for your SSH key. It will not appear as you type it, so make sure you get it right the first time. Press
Enter
after typing the password that you come up with. -
After seeing the randomart image associated with your SSH, you should be able to type a new command. Type
cat ~/.ssh/id_rsa.pub
and pressEnter
. Your key will appear— remember that this should not be shared with others. The key begins withssh-rsa
and it may end with your username. Copy this entire key by clicking and dragging over it, right-clicking, and clickingCopy
. -
Return to your web browser which is on the GitHub SSH key settings page. Click the green button that reads
New SSH Key
and type a Title for this key. You should name it something memorable and distinct; for example, if you just generated the key on your desktop computer, a suitable name isDesktop
. If generated on your laptop, name itLaptop
, or if you have numerous laptops, differentiate them with distinct names, and so on.- If you only have one computer and you have preexisting keys on this page, maybe some which you do not remember the password to or have fallen out of use, consider deleting them (as long as you are sure this will not break anything).
-
Paste the key into the key box. You should have copied it from Git Bash in Step #5. Then, click the green button that reads
Add SSH key
. Congratulations— you have successfully configured your SSH key. Now we will try cloning your REU repository. -
Navigate to your repository. It should be in the cybertraining-dsc directory with a name format of
xxxx-reu-xxx
. Once you are on that page, click the green button that readsCode
with a download symbol. Click theSSH
option and click on the clipboard next to the link so that you copy it. It should sayCopied!
after you click on it. -
Decide where you want your repository folder to be stored. This tutorial will clone the repo into the Documents folder. Go back to Git Bash and type
cd ~/Documents
and pressEnter
. It is a good idea to create a folder titledreu
for organization. Typemkdir reu
and pressEnter
. Typecd reu
and pressEnter
. Finally, typegit clone
, and after you put a space after clone, paste the copied link from GitHub. For example, your command should look similar to this:git clone git@github.com:cybertraining-dsc/su21-reu-361.git
Then, pressEnter
.- The shortcut
Ctrl + V
does not work in Git Bash for pasting. Instead, you can pressShift + Insert
to paste.
- The shortcut
-
Type in your password for your SSH key and press
Enter
. The repo should clone with no issue. You can now typecode .
and pressEnter
to open VSCode in this directory. ClickYes, I trust the authors
if prompted in VSCode. If you use PyCharm instead of VSCode, you can open it from Windows search; inside of PyCharm, clickFile
,Open...
and then navigate toC:
,Users
, your username,Documents
, and then click onreu
so it is highlighted in blue and then clickOK
. If PyCharm asks, you can choose to open it inThis Window
or aNew Window
.
7 - Installing Python
Abstract
This tutorial teaches how to install Python on Windows 10. It can be similarly installed also on macOS and Linux.
Contents
Keywords: python
Windows
Click the following image to be redirected to a 2-minute YouTube walkthrough.
-
First, open the url https://www.python.org/downloads/ in any web browser.
-
As of June 2021, the latest version of Python is
3.9.6
. You may see a different number. We recommend you use the newest official version which is provided to you by simply clicking the button under “Download the latest version for Windows”. -
Once the download has completed, open the file by clicking on it in your Downloads pane.
-
Be sure to check the box that reads “Add Python x.x to PATH”. This will allow you to run commands from the terminal/command prompt.
-
Click “Install Now”. The default options that entail this selection are appropriate.
- The UAC prompt will pop up. UAC stands for “User Account Control” and exists so that the computer will not have unauthorized changes performed on it. Click “Yes” because Python is safe. School-issued computers may ask for an administrator password, so contact your IT department or professor.
-
The installation will take some time.
-
If the setup was successful, then it will say so. Click “Close”.
-
Click the “Type here to search” box in the bottom-left of the screen, type “cmd”, and press Enter.
- An alternative method is to press the Windows key and the “R” key at the same time, type “cmd”, and press Enter. This is convenient for those who like to use the keyboard.
-
Type
python --version
and the output should read “Python x.x.x”; as long as it is the latest version from the website, congratulations. Python is installed on the computer.
Mac
Click the following image to be redirected to a 5-minute YouTube walkthrough. (Yes, Mac’s video is a little longer, but do not fret! You can skip to the 1:00 minute mark if you are in a hurry.)
-
First, open the url https://www.python.org/downloads/ in any web browser.
-
Underneath
Download the latest version for Mac OS X
, there should be a yellow button that readsDownload Python x.x.x
. Click on it, and the download should commence. -
Once the download finishes, open it by clicking on it. The installer will open. Click
Continue
, clickContinue
again, and clickContinue
again. Read the agreements. -
Click
Agree
.- If you want to check how much free storage you have on your computer, click the Apple icon in the top left of your computer. Click
About This Mac
and then click onStorage
. As of July 2021, Python takes ~120 MB of space. Remember that 1 GB = 1000 MB.
- If you want to check how much free storage you have on your computer, click the Apple icon in the top left of your computer. Click
-
Click
Install
. Enter your password and press Enter. The installation will take a while. -
A Finder window will open. You can close it as it is unnecessary. Click
Close
in the bottom-right of the installer. ClickMove to Trash
because you do not need the installer anymore. -
Next confirm that Python installed correctly. Click the magnifying glass in the top-right of your screen and then type
terminal
into Spotlight Search. Double-clickTerminal
.- The terminal will be used frequently. Consider keeping it in the dock for convenience. Click and hold the Terminal in the dock, go to
Options
, and clickKeep in Dock
.
- The terminal will be used frequently. Consider keeping it in the dock for convenience. Click and hold the Terminal in the dock, go to
-
Type
python3 --version
into the terminal and press Enter. It should output the latest version of Python. Congratulations!
Linux
Click the following image to be redirected to a 9-minute YouTube walkthrough. (Linux’s tutorial is the longest, but it is worth it.) This tutorial uses Ubuntu, but it should work on other Linux distros, as well.
- Naturally we recommend that you read all of the licensing information.
-
First, open the url https://www.python.org/downloads/ in any web browser.
-
Look at the latest version. It is on the yellow button:
Download Python x.x.x
. You do not need to click this button. Remember this version number. -
Open a terminal by pressing the Windows key or by clicking the grid on the bottom left of your screen. Type
terminal
. Click on theTerminal
result that appears. -
Next, prepare your system:
Note: If you want to check how much disk space you have, you can use
$ df -h /
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk1s5s1 1.8Ti 14Gi 387Gi 4% 553757 19538475003 0% /
The value under Avail will be your available space. Make sure you have sufficient space.
$ sudo apt-get update
$ sudo apt install -y wget curl
$ sudo apt install -y openssl libssl-dev
$ sudo apt install -y build-essential zlib1g-dev libncurses5-dev
$ sudo apt install -y libgdbm-dev libnss3-dev libreadline-dev libffi-dev libsqlite3-dev libbz2-dev
-
After this finishes, type
cd /opt
and press Enter. Then, remember which version you read on the Python webpage (the latest version) and add it as environment variablePV
to your terminal so we can more easily execute commands that include the version number. Type:$ PV=3.9.6 $ sudo wget https://www.python.org/ftp/python/$PV/Python-$PV.tgz $ sudo tar xzvf Python-$PV.tgz $ cd Python-$PV $ ./configure --enable-optimizations $ make $ sudo make altinstall
-
Confirm Python’s successful installation by typing
pythonx.x --version
; be sure to replace x.x with the first two numbers of the version number. It should output the latest version number. Congratulations!
Python venv
Before you install packages, you need to create a Python venv in your local environment. We typically do this with
$ python3.9 -m venv ~/ENV3
$ source ~/ENV3/bin/activate
or for Windows executed in git bash
$ python -m venv ~/ENV3
$ source ~/ENV3/Scripts/activate
Troubleshooting
Incorrect Python Version on Command Prompt (Windows)
If the Windows computer has previously installed an older version of Python, running python --version
on Command Prompt may output the previously installed older version. Typing python3 --version
may output the correct, latest version.
8 - Installing Visual Studio Code
Abstract
This tutorial teaches how to install Visual Studio Code on Windows 10.
Contents
Keywords: visual-studio-code
Steps
Click the following image to be redirected to a YouTube video tutorial for installing Visual Studio Code (also called VSCode).
Sidenote: An exasperated reader may wonder, “why go through steps 1-3 when it can be as easy as clicking a link to the VSCode download page?” This would be easier, but hyperlinks (or URLs) are bound to change through the years of website maintenance and alterations. (One could also argue that steps 1-3 could become incorrect, as well, but hopefully they will not.) If you, time-traveler, would like to try your luck, go here: https://code.visualstudio.com/download
If the link works, skip to step 4.
P.S. It should be second-nature to a user to quickly search, find, download, and install a program. It is vital to ensure that the correct program is downloaded and installed, however. Over time, guides like this one can become deprecated, but one must be resilient in problem-solving. Use search engines like Google to find what you are looking for. If one path does not work, take another that will lead to the same destination or a better one.
-
Open up your favorite web browser. This can be done by pressing the Windows key and typing in the name of the browser, like
google chrome
(as long as this browser is already installed on your computer). Then press Enter. -
Once the browser loads, search for
visual studio code
through the address bar. Press Enter and you will see a list of results through the default search engine (Google, Bing, or whatever is configured on your browser). -
Identify the result that reads
code.visualstudio.com
. If using Google, a subresult should readDownload
. Click that link. -
This tutorial assumes that the reader is using Windows. Click the blue link that reads
Windows
. The download will commence; wait for it to finish. -
Click and open the file once it finishes; the license agreement will appear. If you are proficient in legalese, you can read the wall of text. Then, click
I accept the agreement
and clickNext
. -
Click
Next
again; it is best to leave the default install path alone for reproducibility in this experiment. -
Click
Next
again to create a Start Menu folder. Ensure thatAdd to PATH
is checked.Create a desktop icon
can be checked for convenience; it is up to the reader’s choice. Then clickNext
. -
Click Install and watch the green progress bar go at the speed of light. Once completed, click Finish. VSCode will open as long as everything went smoothly.