python常用命令行

python 命令行

  1. 新建虚拟环境

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    # use virtualenv
    virtualenv --no-site-packages venv --python=python3

    # or
    sudo apt-get install python3-venv
    python3 -m venv venv

    # then
    source venv/bin/activate
    pip install wheel

  2. pm2 启动 python

    pm2 start ./src/main.py --name py-demo --interpreter ./venv/bin/python

  3. 生成当前项目的 requirements.txt

    1
    2
    3
    4
    pip freeze
    pip freeze > requirements.txt
    # install
    pip install -r requirements.txt
  4. 修改国内 pip 镜像:

    1
    2
    3
    4
    5
    # ~/.pip/pip.conf

    [global]
    trusted-host = mirrors.aliyun.com
    index-url = https://mirrors.aliyun.com/pypi/simple