Skip to main content

第 1 次实验

Course WorkCondaDatabasePrincipal and Application of DatabaseAbout 3 minAbout 858 words

OS: Ubuntu 22.04.1 LTS

本文使用的一系列脚本及配置文件均可在 liblaf/dotfilesopen in new window 下找到.

1. Python 安装与配置

1.1 安装 Miniconda

安装 Miniconda 的脚本位于 install.shopen in new window, 默认安装至 ~/.local/pkgs/conda/ 下. 由于自己的机器已经配置过 Conda, 不再重复安装.

1.2 为 Conda 指定软件源

详见 .condarcopen in new window 配置文件.

1.3 使用 Conda 配置 Python 环境

❯ conda create --name Liqin2020012872 python=3.9
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /home/liblaf/.local/pkgs/conda/envs/Liqin2020012872

  added / updated specs:
    - python=3.9


The following NEW packages will be INSTALLED:

  _libgcc_mutex      anaconda/pkgs/main/linux-64::_libgcc_mutex-0.1-main None
  _openmp_mutex      anaconda/pkgs/main/linux-64::_openmp_mutex-5.1-1_gnu None
  ca-certificates    anaconda/pkgs/main/linux-64::ca-certificates-2022.07.19-h06a4308_0 None
  certifi            anaconda/pkgs/main/linux-64::certifi-2022.9.24-py39h06a4308_0 None
  ld_impl_linux-64   anaconda/pkgs/main/linux-64::ld_impl_linux-64-2.38-h1181459_1 None
  libffi             anaconda/pkgs/main/linux-64::libffi-3.3-he6710b0_2 None
  libgcc-ng          anaconda/pkgs/main/linux-64::libgcc-ng-11.2.0-h1234567_1 None
  libgomp            anaconda/pkgs/main/linux-64::libgomp-11.2.0-h1234567_1 None
  libstdcxx-ng       anaconda/pkgs/main/linux-64::libstdcxx-ng-11.2.0-h1234567_1 None
  ncurses            anaconda/pkgs/main/linux-64::ncurses-6.3-h5eee18b_3 None
  openssl            anaconda/pkgs/main/linux-64::openssl-1.1.1q-h7f8727e_0 None
  pip                anaconda/pkgs/main/linux-64::pip-22.2.2-py39h06a4308_0 None
  python             anaconda/pkgs/main/linux-64::python-3.9.13-haa1d7c7_1 None
  readline           anaconda/pkgs/main/linux-64::readline-8.1.2-h7f8727e_1 None
  setuptools         anaconda/pkgs/main/linux-64::setuptools-63.4.1-py39h06a4308_0 None
  sqlite             anaconda/pkgs/main/linux-64::sqlite-3.39.3-h5082296_0 None
  tk                 anaconda/pkgs/main/linux-64::tk-8.6.12-h1ccaba5_0 None
  tzdata             anaconda/pkgs/main/noarch::tzdata-2022c-h04d1e81_0 None
  wheel              anaconda/pkgs/main/noarch::wheel-0.37.1-pyhd3eb1b0_0 None
  xz                 anaconda/pkgs/main/linux-64::xz-5.2.6-h5eee18b_0 None
  zlib               anaconda/pkgs/main/linux-64::zlib-1.2.12-h5eee18b_3 None


Proceed ([y]/n)?

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate Liqin2020012872
#
# To deactivate an active environment, use
#
#     $ conda deactivate

Retrieving notices: ...working... done
❯ conda activate Liqin2020012872
❯ conda info

     active environment : Liqin2020012872
    active env location : /home/liblaf/.local/pkgs/conda/envs/Liqin2020012872
            shell level : 2
       user config file : /home/liblaf/.condarc
 populated config files : /home/liblaf/.condarc
          conda version : 22.9.0
    conda-build version : not installed
         python version : 3.9.13.final.0
       virtual packages : __linux=5.15.0=0
                          __glibc=2.35=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /home/liblaf/.local/pkgs/conda  (writable)
      conda av data dir : /home/liblaf/.local/pkgs/conda/etc/conda
  conda av metadata url : None
           channel URLs : https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/noarch
          package cache : /home/liblaf/.local/pkgs/conda/pkgs
                          /home/liblaf/.conda/pkgs
       envs directories : /home/liblaf/.local/pkgs/conda/envs
                          /home/liblaf/.conda/envs
               platform : linux-64
             user-agent : conda/22.9.0 requests/2.28.1 CPython/3.9.13 Linux/5.15.0-48-generic ubuntu/22.04.1 glibc/2.35
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False

1.4 安装 PyQt 及其依赖项

软件源配置相见 pip.confopen in new window.

❯ pip list
Package          Version
---------------- ---------
certifi          2022.9.24
click            7.1.2
packaging        21.3
pip              22.2.2
ply              3.11
pyparsing        3.0.9
PyQt6            6.1.0
pyqt6-plugins    6.1.0.2.2
PyQt6-Qt6        6.4.0
PyQt6-sip        13.4.0
pyqt6-tools      6.1.0.3.2
python-dotenv    0.21.0
qt6-applications 6.1.0.2.2
qt6-tools        6.1.0.1.2
setuptools       63.4.1
sip              6.7.1
toml             0.10.2
wheel            0.37.1

2. MySQL 安装与配置

使用 Homebrew on Linuxopen in new window.

❯ brew info mysql
==> mysql: stable 8.0.30 (bottled)
Open source relational database management system
https://dev.mysql.com/doc/refman/8.0/en/
Conflicts with:
  mariadb (because mysql, mariadb, and percona install the same binaries)
  percona-server (because mysql, mariadb, and percona install the same binaries)
/home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.30_1 (314 files, 278.1MB) *
  Poured from bottle on 2022-10-09 at 16:53:47
From: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git/Formula/mysql.rb
License: GPL-2.0-only with Universal-FOSS-exception-1.0
==> Dependencies
Build: cmake ✔, pkg-config ✔, patchelf ✘
Required: icu4c ✔, libevent ✔, libfido2 ✔, lz4 ✔, [email protected] ✔, protobuf ✔, zlib ✔, zstd ✔, curl ✔, cyrus-sasl ✔, libedit ✔, libtirpc ✔
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -u root

To restart mysql after an upgrade:
  brew services restart mysql
Or, if you don't want/need a background service you can just run:
  /home/linuxbrew/.linuxbrew/opt/mysql/bin/mysqld_safe --datadir=/home/linuxbrew/.linuxbrew/var/mysql
==> Analytics
install: 102,796 (30 days), 322,409 (90 days), 1,108,015 (365 days)
install-on-request: 102,512 (30 days), 321,510 (90 days), 1,104,544 (365 days)
build-error: 281 (30 days)

启用 MySQL 服务

❯ brew services start mysql
Created symlink /home/liblaf/.config/systemd/user/multi-user.target.wants/homebrew.mysql.service → /home/liblaf/.config/systemd/user/homebrew.mysql.service.
Unit /home/liblaf/.config/systemd/user/homebrew.mysql.service is added as a dependency to a non-existent unit multi-user.target.
==> Successfully started `mysql` (label: homebrew.mysql)
❯ brew services info mysql
mysql (homebrew.mysql)
Running: ✔
Loaded: ✔
Schedulable: ✘
User: liblaf
PID: 108384

测试 MySQL 连接

❯ mysql --user root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.30 Homebrew

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

3. VSCode 安装与配置

安装脚本位于 install.shopen in new window.