美文网首页
pipenv 的安装和使用

pipenv 的安装和使用

作者: momo1023 | 来源:发表于2019-11-29 14:53 被阅读0次

安装

  • ubuntu
$ sudo apt install software-properties-common python-software-properties
$ sudo add-apt-repository ppa:pypa/ppa
$ sudo apt update
$ sudo apt install pipenv
  • windows
$ pip install pipenv
  • mac os
$ brew install pipenv

使用

创建虚拟环境

前提是已经安装 python2 和 python3

$ cd project
$ pipenv --three  # python3 环境
$ pipenv --two  # python2 环境
$ pipenv --python 3.6  # 指定版本

激活虚拟环境

$ pipenv shell

安装依赖

$ pipenv install requests
$ pipenv install django==1.11

查看目前安装的库及其依赖

$ pipenv graph

显示虚拟环境信息

$ pipenv --venv

显示Python解释器信息

$ pipenv --py

显示目录信息

$ pipenv --where

检查安全漏洞

$ pipenv check

卸载依赖包

$ pipenv uninstall requests
$ pipenv uninstall --all  # 卸载全部包

退出虚拟环境

$ exit

删除虚拟环境

$ pipenv --rm

修改源

创建环境后,项目根目录会多出来两个文件:PipfilePipfile.lock
查看pipfile

$ cat Pipfile

显示如下:

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

[packages]
requests = "*"

[dev-packages]

[requires]
python_version = "3.7"

修改 url 中对应的 pip 源即可:

url = "https://pypi.tuna.tsinghua.edu.cn/simple/"

常用的源:

相关文章

网友评论

      本文标题:pipenv 的安装和使用

      本文链接:https://www.haomeiwen.com/subject/upqgwctx.html