python包管理

1.1 包管理

1.1.1 查看包

pip list查看已经安装的第三方库

pip list --outdated:可以查看有新版本的第三方库,可显示现在安装的版本,以及最新的版本

查看安装库的详细信息,命令:pip show 库名

1.1.2 安装包

使用pip的方式安装,pip默认是国外的源,安装会受网络因素的影响。

pip install -i https://pypi.mirrors.ustc.edu.cn/simple/ django # 默认安装最新版本的Django

pip install -i https://pypi.mirrors.ustc.edu.cn/simple/ django==2.2 # 指定版本

安装后验证:

其他pip源:

1) 阿里云 http://mirrors.aliyun.com/pypi/simple/

2) 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

3) 豆瓣(douban) http://pypi.douban.com/simple/

4) 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

5) 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

1.1.3 查看要安装的包有哪些版本

pip install PySide2==

直接官网搜索发布历史

https://pypi.org/project/Appium-Python-Client/#history

1.1.4 卸载包

卸载第三方库命令:pip uninstall 库名

1.1.5 导出当前环境包

导出命令为:pip freeze > filename.txt

在新环境下安装移植项目依赖的三方库方法为:pip install -r filename.txt

1.1.6 导出项目依赖包

参考:https://blog.csdn.net/DeMeng33/article/details/104005982

$pip3 install pipreqs
$cd 到项目
$pipreqs ./
$pip3 install -r requirements.txt

$pip3 search pipreqs

pipreqs (0.4.10) - Pip requirements.txt generator based on imports in project

pipreqs-amasad (0.4.10) - Pip requirements.txt generator based on imports in project

pipreqs-spenly (0.4.10) - Pip requirements.txt generator based on imports in project

pipreqs-update (2019.4.13) - update pip requirements file with latest versions

$pipreqs -h

pipreqs - Generate pip requirements.txt file based on imports

Usage:

pipreqs [options] [<path>]

Arguments:

<path> The path to the directory containing the application

files for which a requirements file should be

generated (defaults to the current working

directory).

在项目目录下执行,如果已经有一个req文件还需要带上--force来覆写。

WARNING: Requirements.txt already exists, use --force to overwrite it

在我们生成requrequirements.txt 可能会报编码错误
(UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 939: illegal multibyte sequence)只要我们在后面加入指定编码,例:pipreqs ./ --encoding=utf8就可以了

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值