zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    10月27号
    10月23号
    10月26号
    10月30号
    10月28号
    10月29号
    JAVA日报
    JAVA日报
    JAVA日报
    JAVA日报
  • 原文地址:https://www.cnblogs.com/ingen42/p/11000306.html
Copyright © 2011-2022 走看看