Skip to Main Content

python record

Install

  • Install Python3.12 (suitable for multiple version management) using pyenv (is the classic preferred to manage Python version on Linux/macOS)

Scenario record involved: this method is used when DeerFlow is installed

# 1. Install pyenv dependencies
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. Install pyenv
curl https://pyenv.run | bash
# 3. Configure pyenv environment variables
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
source ~/.bashrc
# 4. Install Python3.12.4
pyenv install 3.12.4
# 5. Set global Python3.12.4
pyenv global 3.12.4
# 6. Verify installation
python --version
pip --version
  • uv (current red bomb chicken) (keyword:fast!Very fast!) (Speed (Rust write), Full Energy (plug + pack+ item))

Official one-click script installation (curl -LsSf https://astral.sh/uv/install.sh | sh)

  • Other options

Stack (Node+Python+Ruby), optional asdf

as long as environmental isolated, regardless of version, optional Docker

ipynb Usage

Install Module 参考文章

import sys
!{sys.executable} -m pip install matplotlib

Use in vscode

Related plugins: Polyglot Notebooks(Extended Id: ms-dotnettools.dotnet-interactive-vscode)

# Dependencies
get https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
chmod +x ./dotnet-install.sh
./dotnet-install.sh