0%

pip 命令找不到?

有些人刚开始用 Python 可能会有

1
pip: command not found

原因有二:

  • pip 所在路径不在环境变量内
  • 你没装 pip

下面分系统说明下

MacOS / Linux

安装了 conda

如果你安装了 anaconda 或者 miniconda,它所安装的文件夹下有个bin文件夹,需要把他放到环境变量内。

此处以安装了 anaconda 为例,安装路径在~/anaconda

一般命令行是 bash 的,zsh 或者其他的也差不多,下面文件名换个名字而已。下面以 bash 为例。

1
2
3
4
5
6
7
8
vim ~/.bashrc

# 按 i 进入键入模式
# 添加以下一行
PATH=$PATH:~/anaconda
# 按 esc,再输入:wq 然后回车保存退出

source ~/.bashrc # 或者重新开一个命令行窗口

然后检验一下

1
pip --version

应该可以了


如果还是不行,给个江湖救急的法子

首先你要确定~/anaconda/bin下的确有个叫pip的文件(比如用 finder 看)

1
2
3
4
cd ~/anaconda/bin
pip install <module>
# 如果还是不行
./pip install <module>

如果你对./pip里的点.好奇的话,可以砍这里

其他路径下则

1
~/anaconda/bin/pip install <module>

如果上面有一种情况你成功了,那你还有一丝希望,拯救你使用冗长的 pip 命令

1
2
3
vim ~/.bashrc
# 加入这行
alias pip=~/anaconda/bin/pip

用系统自带的 python

1
sudo easy_install pip

Windows

安装了 conda

如果你安装了 anaconda 或者 miniconda,同样把它的bin文件夹添加到环境变量。

windows 添加环境变量方法请自行百度。

安装了官方 python

那你估计真的安装出了问题?

MySQL 安装

MacOS

  1. 下载
    download from https://dev.mysql.com/downloads/mysql/, select macOS 10.14 (x86, 64-bit), DMG Archive(.dmg file)

顺路会看到一个叫 workbench 的,可视化工具,就像看 excel 看数据库,which is recommended.

  1. 安装
    clike next all the way.

set the PATH

1
2
3
vim ~/.bash_profile
# 增加以下这行
PATH=$PATH:/usr/local/mysql/bin

Windows

同样在https://dev.mysql.com/downloads/mysql/下载,略。

Ubuntu

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# download the configuration
wget https://dev.mysql.com/get/mysql-apt-config_0.8.14-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.14-1_all.deb
# default is fine, select OK and return

sudo apt update
sudo apt-get install mysql-server
# set password(spa2020)
# use strong password encryption

sudo mysql_secure_installation
# enter password
# n (不换root密码)
# Remove anonymous users? : y(删除匿名用户)
# Disallow root login remotely?: n(是否禁止 root 远程登录)
# Remove test database and access to it? : y(删除测试数据库)
# Reload privilege tables now? : y(立即重新加载特权表)

mysql -V # check version
# mysql Ver 8.0.19 for Linux on x86_64 (MySQL Community Server - GPL)

WSL

参见此文

macOS 和 Windows 下可以装个数据库 GUI app

  • MySQL Workbench (free & recommend)
    如同处理 excel,不用学 mysql 命令也能操作数据库啦

MacOS 自动化 tricks

AppleScript

SideCar

1
2
3
4
5
6
tell application "System Events"
tell process "SystemUIServer"
click (menu bar item 1 of menu bar 1 whose description contains "Displays")
click menu item "[YOUR iPAD HERE]" of menu 1 of result
end tell
end tell

from https://github.com/Jcowwell/Sidecar-Scripts

Click icon on the right side of menubar

1
2
3
4
5
6
7
8
tell application "System Events"
# focus(when full screen)
control down
# click actions
tell application "System Events" to tell process "[APP PROCESS NAME]"
click menu bar item 1 of menu bar 2
end tell
end tell

with Keyboard Maestro

Multi-displays

Chrome 关闭下方 download 栏

chrome

在 VS Code 中给 Markdown 增加排版自由度

VS Code 插件选择Instant Markdown,在浏览器 preview,因为 vscode 的侧栏显示 style 有限制。

Install & Configuration

如果你想偷懒:https://github.com/Benature/vscode-instant-markdown

为了加入自己的 css,对插件做点加工(手脚)

  1. 前往插件所在文件夹
    eg: mac 下路径:/Users/benature/.vscode/extensions/dbankier.vscode-instant-markdown-1.4.4

原本的结构目录是

1
2
3
4
5
6
7
8
9
10
11
12
13
.
├── README.md
├── index.html
├── jsconfig.json
├── node_modules
│ └── ...
├── out
│   └── src
│   ├── extension.js
│   └── server.js
├── package-lock.json
├── package.json
└── vscode-instant-markdown.gif
  1. 新建一个public文件夹,把自己的 css 文件放进去
1
2
3
4
5
6
7
8
.
├── public
│ └── bootstrap
│ │ ├── bootstrap.min.css
│ │ └── ...
│ └── muyi.css
├── ...
...
  1. index.html文件内假如对自定义 css 的引用(或者在 md 文件内引用也可以)
1
2
<link rel="stylesheet" href="bootstrap.min.css">
<link rel="stylesheet" href="muyi.css">

到这里还不够,否则在网页打开 console 会看到自定义的 css 是 404 的

  1. 把文件加到 server 里去

out/src/server.js

1
2
3
4
5
6
app.get('/muyi.css', function (req, res) {
res.sendfile(path.resolve(__dirname, '..', '..', 'public', 'muyi.css'));
});
app.get('/bootstrap.min.css', function (req, res) {
res.sendfile(path.resolve(__dirname, '..', '..', 'public', 'bootstrap', 'bootstrap.min.css'));
});

混入到其他app.get的代码里去,配置完成。

Usage

多列显示

1
2
3
4
5
6
7
<div class="d-flex flex-row justify-content-between"><div>

第一列
</div><div>

第二列
</div></div>

这里的 class 用的是 bootstrap 的。

Notion 原生对分列显示是比较 limited 的,比如分列后不能再仅针对某一行分列,只能在整一列的基础上右边再加一列。用 html 的不断 div 嵌套可以无限分列分行。

Toggle List

1
2
3
4
5
<b><details open><summary>显示标题</summary></b>

隐藏内容
details 节点内的 open 使得 Toggle List 默认打开
</details>

Callout

选择了 Hexo 内的 note 类装饰来代替

1
2
3
4
5
6
7
<div class="note b-green">

### notion-like callout

- list 1
- list 2
</div>

需要配置相应的 css,或者把插件原生的 css 换了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
.note {
border-top-color: rgb(238, 227, 207);
border-right-color: rgb(238, 227, 207);
border-bottom-color: rgb(238, 227, 207);
border-left-color: rgb(238, 227, 207);

margin-bottom: 20px;
padding: 15px;
position: relative;
border: 1px solid #eee;
border-left-width: 5px;
border-radius: 3px;

}
.note p{
margin-bottom:0;
}
.b-green {
border-left-color: #5cb85c;
}
.b-blue {
border-left-color: #428bca;
}

还有一种方法是用 Mardown Preview EnhancedLive Server两个插件组合使用,配置 css 的引用会方便些,但是相对 Instance Markdown 的劣势在于不能实时 preview,需要保存先。因为目前的 MPE 的 open in browser 不是 live 的。

Git 多人协作

不开分支多人协作的后果—— git 自动用旧代码覆盖新的更改

主干分支与个人分支的合并

在个人分支 commit 后

1
2
3
4
5
6
7
8
git checkout dev
git pull
git merge --no-ff personal_branch # --no-ff: 禁用 fast forward 模式
# resolve conflict
git push

git checkout personal_branch
git reset --hard dev

merge 和 rebase 的区别

引用知乎的回答:

可以这么说:merge是显性合并,rebase是隐性合并。
同理,当你执行git pull时,是同时执行了git fetch 和 git merge两个操作。如果你不想进行merge操作,即不想留下合并的记录,可以使用 git pull —rebase操作。

SourceTree 下的 merge

  • Aim: merge branchA into main
  1. double click branchA on the side bar of branches.
  2. select the commit and right click, select commit.

Significant: checkout to the branch which is to be merged with. (branchA in this case)

Github Desktop 下的 merge

参考这个,不再赘述。


Reference: