python记录
安装
- 使用 pyenv 安裝 Python3.12(適合多版本管理)(是 Linux/macOS 上管理 Python 版本 的經典首選)
涉及的場景記錄: 在安裝 DeerFlow 時, 用到了這種方式
# 1. 安裝 pyenv 依賴
sudo apt install git curl build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl -y
# 2. 安裝 pyenv
curl https://pyenv.run | bash
# 3. 配置 pyenv 環境變數
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
source ~/.bashrc
# 4. 安裝 Python3.12.4
pyenv install 3.12.4
# 5. 設定全局使用 Python3.12.4
pyenv global 3.12.4
# 6. 驗證安裝
python --version
pip --version
- uv (當下的當紅炸子雞)(關鍵詞:快!非常快!)(極速 (Rust 編寫)、全能 (管版本 + 包 + 項目))
官方一鍵腳本安裝(curl -LsSf https://astral.sh/uv/install.sh | sh)
- 其他選擇
全棧 (Node+Python+Ruby), 可選asdf
只要環境隔離,不管版本, 可選Docker
ipynb使用
安装模块 参考文章
import sys
!{sys.executable} -m pip install matplotlib
vscode中使用
相关插件: Polyglot Notebooks(扩展Id: ms-dotnettools.dotnet-interactive-vscode)
# 需要安装的依赖
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
chmod +x ./dotnet-install.sh
./dotnet-install.sh