Basic

安装Python

  1. 手动下载安装python https://www.python.org/downloads/
  2. test python -V in terminal
$ python -V
## Python 3.12.0

创建项目

# 新建目录
$ mkdir <project>
$ cd <project>

# init git
<p>$ git init

# gitignore

## windows powershell
<p>$ powershell Start-BitsTransfer -Source https://www.toptal.com/developers/gitignore/api/python -Destination .gitignore

## linux
<p>$ wget https://www.toptal.com/developers/gitignore/api/python -O .gitignore
<p>$ curl https://www.toptal.com/developers/gitignore/api/python -o .gitignore

# 创建虚拟环境
<p>$ python -m venv <venvName>

# 激活虚拟环境
## linux 
<p>$ source <venvName>/bin/activate

## windows
<p>$ <venvName>\Scripts\activate

## 安装依赖
<venvName>$ pip install numpy

## 保存依赖
<venvName>$ pip freeze > requirements.txt


## coding
<venvName>$ touch main.py

## run
<venvName>$ python main.py

refs:

使用项目

$ git clone <github:project>
$ cd project

# 创建虚拟环境
<p>$ python -m venv <venvName>

# 激活虚拟环境(上面)

# 根据依赖文件安装依赖
<venvName>$ pip install -r requirements.txt

Pip

Trouble Shooting

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.