Python 开发环境

1. Overview

fnm/electron/nextjs Windows WSL Container
开发环境(VS Code with Extension)

2. Windows

使用 pyenv-win 管理python版本

2.1. pyenv-win

1
2
3
# install pyenv-win
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1" -OutFile "./install-pyenv-win.ps1"; &"./install-pyenv-win.ps1"

2.2. python

1
2
3
4
5
6
7
8
9
10
11
# list all available Python versions
pyenv install -l

# install a Python version
pyenv install 3.12.6

# set a Python version to use globally
pyenv global 3.12.6

# set pip mirror
pip config --user set global.index-url "https://mirrors.aliyun.com/pypi/simple/"

3. WSL

使用 pyenv 管理python版本和虚拟环境

3.1. pyenv

1
2
3
4
5
6
7
8
9
# install pyenv
curl https://pyenv.run | bash

cat >> ~/.profile <<- 'EOF'

# pyenv
PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
EOF

3.2. python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# install python build dependencies
sudo apt update; sudo apt install -y build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl git \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

# list all available Python versions
pyenv install -l

# install a Python version
pyenv install 3.12.6

# set a Python version to use globally
pyenv global 3.12.6

# set pip mirror
pip config --user set global.index-url https://mirrors.aliyun.com/pypi/simple/

4. Container

参考 项目模板Python

作者

Michael Ding

发布于

2024-11-09

更新于

2024-11-09

许可协议