xxxxx

pipenv的基本使用

 

功能类似Node.js中的npm

安装

pip install pipenv
pipenv --version

使用

  • 创建并进入到项目文件夹
  • 指定版本创建环境
    pipenv --python 3.6
  • 激活虚拟环境
    pipenv shell

退出
exit

  • 安装模块
    pipenv install flask

安装只在开发环境中使用的包
pipenv install --dev pytest

  • 查看依赖关系
    pipenv graph
  • 项目迁移
    项目迁移到另一环境中,将代码和Pipfile文件拷贝过去,并运行命令。

pipenv install --dev

  • 查看当前虚拟环境目录
    pipenv --venv

当前项目根目录
pipenv --where

  • 删除虚拟环境
    pipenv --rm
  • requirements.txt转化为Pipfile
    pipenv install命令会自动检测requirements.txt并生成Pipfile

pipenv install -r requirements.txt --dev

  • 运行
    pipenv run python main.py

Pipfile

    [[source]]
    name = "pypi"
    url = "https://pypi.org/simple"
    verify_ssl = true

    [dev-packages]  //开发环境
    pytest = "*"

    [packages]      //生产环境
    flask = "*"
    py-test = "*"

    [requires]
    python_version = "3.6"

    [scripts]       //自定义脚本
    start = "python main.py"    //运行pipenv run start
posted @ 2019-06-10 21:17  St4ndAlone  阅读(271)  评论(0编辑  收藏  举报
i still love you