CS61A 2022 fall lab0:Getting Started

不得不感叹实验网站是真的高级…

打算用ubuntu做实验

文章目录

  • CS61A 2022 fall lab0:Getting Started
  • Introduction
  • Setup
    • 1.Install a terminal
    • 2.Install Python 3
      • Python3.7
        • 基于update-alternatives的Python默认版本系统级修改:屡试屡败...
        • 基于软链接的Python版本系统级修改
      • Python3.9
    • 3.Install a text editor
      • (1)试试vscode的 remote development
      • (2)学学Vim
        • ①Introduction
        • ②Goals
        • ③Getting Vim on your own computer
        • ④Example: `greet.py`
          • Opening files
          • Normal mode and Insert mode
          • Editing files
          • Saving files
          • Running Python
          • Closing Vim
          • Summary
        • ⑤Keyboard Shortcuts
          • Different modes
          • Navigating
          • Entering Insert mode
          • Undo and redo 实用芜湖!
          • Deleting text (like cut,删了可以复制回来,相当于剪切)
          • Copying text
          • Pasting text
          • Searching
          • Visual mode
        • ⑥Customizing Vim
          • Syntax highlighting
          • Line numbers
          • Tabs
          • Key bindings
    • 4.Pair Programming
    • 5.Backup setups
      • Soda lab computers
      • Online editors as a backup
  • Walkthrough:Using the terminal
    • 1.Home Directory
    • 2.Path
    • 3.Terminal vs Python Interpreter
  • Walkthrough:Organizing your files
    • 给阿里云轻量应用服务器配置图形界面
    • Directories
    • Changing directories
      • macOS/Linux
    • Making new directories
      • macOS/Linux
    • More directory changing
    • Downloading the assignment
      • 将文件从windows上传到Linux上面
        • 方法1 scp指令
        • 方法2 xftp 7
    • Extracting starter files
    • Moving files
    • Summary
  • Review:Python basics
    • 安装vscode
    • python review
      • Primitive Expressions 原始表达式
      • Arithmetic Expressions
      • Strings
      • Assignment Statements 赋值表达式
  • Required: Doing the assignment
    • What Would Python Do? (WWPD)
      • Using OK
        • Signing in with Ok
          • Troubleshooting
            • Not enrolled
            • Wrong email
            • Can't authenticate/browser issues/redirections to `127.0.0.1`/etc.
            • Crashed or did not load
        • Testing with Ok
          • Test specific questions
          • Test all questions
          • Display all tests
          • Test locally (貌似这个可以???)
          • Adding your own tests
          • Running your own tests
          • Submit assignment
          • Viewing submissions
    • Code writing questions
      • Understanding problems
      • Writing code
    • Running tests
  • Required:Submitting the assignment (无账号的局外人 看看热闹罢了
    • Step 1: Submit with `ok`
    • Step 2: Verify your submission
  • Appendix:Useful Python command line options
  • 一些总结
  • 参考资源

Introduction

emmm 还有个顺带的目的是学英语,所以复制过来让自己也看一看一些地道的表达

This lab explains how to setup your computer to complete assignments and introduces some of the basics of Python.

This lab is required. The setup is necessary in completing all other assignments in the course.

This lab looks really long, but it’s mostly setup and learning how to use the essential tools for this class. These may seem a bit difficult now, but will quickly become second nature as we move further into the course.

become second nature 好地道的用法~

Here’s a breakdown of the major parts of the lab:

  • Setup: Setting up the essential software for the course. This will require several components, listed below.

    • Install a Terminal: Install a terminal so you can interact with files in this course and run OK commands. If you have a terminal on your computer and feel comfortable using it, you can skip this part.
    • Install Python 3: Install the Python programming langauge to your computer. If you already have Python 3.7 or later (ideally Python 3.9) installed, you can skip this part.
    • Install a Text Editor: Install software to edit .py files for this course (e.g. VSCode, Atom, etc.). You can skip this part if you already have a text editor you like.
  • Walkthrough: Using the Terminal: This walks you through(walk sb through,耐心地给某人示范) how to use the terminal and Python interpreter. If you already feel comfortable with both of these you do not need to read this section.
  • Walkthrough: Organizing your Files: This section walks you through how to use your terminal to organize and navigate files for this course. Everyone should at least skim(浏览) this section, as it has important information specific to this class, but if you are already comfortable navigating directory structures with a terminal much of this will feel familar.
  • Review: Python Basics: This is a review on many of the basic components of Python introduced in lecture. You should have already seen this material, but we like to include a brief review of relevant content on each lab in case you need a refresher (你需要复习一下)on anything.
  • Required: Doing the Assignment: You must complete this section to get points for the assignment. Here you will practice the different types of problems you will be asked to do in lab, homework, and project assignments for this course. The main goal of this assignment is to give you practice using our software.
  • Required: Submitting the Assignment: You must complete this section to get points for the assignment. This will walk you through how to turn in your work after completing the previous section and how to verify that your work is turned in on OKPY.
  • Appendix: Useful Python Command Line Options: These are commands that are useful in debugging your work, but not required to complete the lab. We include them because we imagine they’re likely to be helpful to you throughout the course.

Setup

lab教程真的是循序渐进,十分详实啊

1.Install a terminal

  • macOS/Linux:already have a program called Terminal

    打算拿阿里云上搞的一个ubuntu来试试

  • Windows

    • Option1:WSL(the Windows subsystem for Linux)

      感觉推荐这个,足见课程的先进…

    • Alternative option:Windows Powershell

2.Install Python 3

Python3.7

  • 看到这里以为装3.7就行,没想到后面还得装个3.9

基于update-alternatives的Python默认版本系统级修改:屡试屡败…

Ubuntu 18.04默认已经安装Python 2.7与Python 3.6,

  • Installing Python3

    针对每种操作系统都给出了教程

    • Linux:sudo apt install python3

    • 我的阿里云服务器已经自带了,但是默认python2是python2.7.15rcl,默认的python3是python3.6

    • 于是我参照这篇博客折腾了一下,将默认的设置为了3.7

      • 首先看看python在哪

        whereis python
        python: /usr/bin/python /usr/bin/python3.6m /usr/bin/python3.6 /usr/bin/python2.7 /usr/lib/python3.6 /usr/lib/python2.7 /usr/lib/python3.7 /etc/python /etc/python3.6 /etc/python2.7 /usr/local/lib/python3.6 /usr/local/lib/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz
        
      • 可使用 update-alternatives 来为整个系统更改 Python 版本。

        • 首先罗列出所有可用的 python 替代版本信息:

          update-alternatives --list python
          update-alternatives: error: no alternatives for python
          

          出现以上所示的错误信息,表示 Python 的替代版本尚未被 update-alternatives 命令识别

        • 我们需要更新一下替代列表,将 python2.7python3.6python3.7 放入其中

          update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
          update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode
          update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
          update-alternatives: using /usr/bin/python3.6 to provide /usr/bin/python (python) in auto mode
          update-alternatives --install /usr/bin/python python /usr/lib/python3.7 3
          update-alternatives: using /usr/lib/python3.7 to provide /usr/bin/python (python) in auto mode
          
        • 我们再list一下

        • 再配置一下

          sudo update-alternatives --config python
          There are 3 choices for the alternative python (providing /usr/bin/python).Selection    Path                Priority   Status
          ------------------------------------------------------------
          * 0            /usr/lib/python3.7   3         auto mode1            /usr/bin/python2.7   1         manual mode2            /usr/bin/python3.6   2         manual mode3            /usr/lib/python3.7   3         manual modePress <enter> to keep the current choice[*], or type selection number: 3
          
      • 原以为配置大功告成了,结果…麻了

    • python居然变成了directory…我猜是因为我的python3.7是在usr/lib/目录下,而不是在usr/bin目录下,于是去做了一些尝试

      把配置调为usr/bin/python3.6,再试试

      接下来分别尝试python2、python3、python指令,结果如下

      去看看那个python3.7到底咋回事…

      呃不知道为啥一堆乱码

      再去usr/bin目录下看到了python和python3.6

      image-20221214155714107

  • 得重新整理下思路了…

    • 一方面python3.7得重装一下,先贴几个可能的参考资料在这

      • ubuntu安装python3.7
      • Ubuntu上安装Python3.7
      • 如何在 Ubuntu 18.04上安装 Python3.7
    • 另一方面那个config得再研究研究
      • Ubuntu 18.04将Python3设置为Python默认版本
      • Ubuntu修改默认Python版本
      • Ubuntu更改默认python版本
      • Linux下切换Python版本的3种方法
      • Ubuntu16.04下完美切换Python版本
  • 继续干

    尝试安装python3.7失败

  • emmm 肿么办

    当我转头求助这个教程的时候

    试着安装sudo apt-get install software-properties-common,

    如下

    于是我去google这个问题:Package 'software-properties-common' has no installation candidate,看到了一个解答

  • 于是sudo apt-get update,好耶!
  • 然后选择yes

image-20221218015808077