pythonpipenv的使用
python中pipenv的使用
1、使用前提
前提:假设我们在用户目录~下有一个项目叫my_project/
我们首先进入项目目录:
cd~/my_project
进入项目后,如果直接执行pipenvvinstall,pipen会根据系统默认的python版本创建一个虚拟环境。(前提是这个项目中不存在现有的Pipfile,如果存在,它会根据Pipfile安装Pipfile中记录的相应版本和依赖库)。
但是我们在创建虚拟环境时通常会指定python版本,这需要匹配两三个参数:
-two使用python2创建虚拟环境。
-three使用python3创建虚拟环境。
pipenvinstall--three#需要确保系统中存在python3版本
2、实例
下面是执行后的输出信息:
Creatingavirtualenvforthisproject…
Using/usr/local/bin/python3tocreatevirtualenv…
#这里可以看到继承自哪个python版本
⠋Runningvirtualenvwithinterpreter/usr/local/bin/python3Usingbaseprefix'/usr/local'
Newpythonexecutablein/root/.local/share/virtualenvs/my_project-dhpIKgdN/bin/python3
Alsocreatingexecutablein/root/.local/share/virtualenvs/my_project-dhpIKgdN/bin/python
Installingsetuptools,pip,wheel...done.
#这里可以看到虚拟环境安装的位置
Virtualenvlocation:/root/.local/share/virtualenvs/my_project-dhpIKgdN
CreatingaPipfileforthisproject…
Pipfile.locknotfound,creating…
Locking[dev-packages]dependencies…
Locking[packages]dependencies…
UpdatedPipfile.lock(625834)!
InstallingdependenciesfromPipfile.lock(625834)…
�▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉0/0—00:00:00
Toactivatethisproject'svirtualenv,runthefollowing:
$pipenvshell#要激活该虚拟环境,执行这条指令
以上就是python中pipenv的使用,希望能对大家有所帮助,更多Python学习教程请关注IT培训机构:千锋教育。

相关推荐HOT
更多>>
python中静态字符串的编码
python中静态字符串的编码1、静态字符串的编码方法取决于报头中的编码设置。在下面的代码中,变量名用UTF-8编码。#!/usr/bin/envpython#coding:...详情>>
2023-11-13 23:57:40
pythonpyg2plot的原理
pythonpyg2plot的原理1、说明PyG2Plot原理其实非常简单,其中借鉴了pyecharts的实现,但是因为蚂蚁金服的G2Plot完全基于可视分析理论的配置式结...详情>>
2023-11-13 21:25:26
python继承的特征有哪些?
python继承的特征有哪些?本文教程操作环境:windows7系统、Python3.9.1,DELLG3电脑。1、概念继承就是一个类可以获得另外一个类中的成员属性和...详情>>
2023-11-13 19:47:58
pythonFileNotFoundError的异常
python中FileNotFoundError的异常1、Python无法读取不存在的文件,因此它引发一个异常:Traceback(mostrecentcalllast):File"alice.py"...详情>>
2023-11-13 19:27:04热门推荐
技术干货






