pip dependency

查看依赖 工具 pipdeptree 支持正向、反向查看依赖 多种格式输出,安装了graphviz还可以输出图形 [root@10-113-57-176 /] pip install pipdeptree [root@10-113-57-176 /] pipdeptree --help usage: pipdeptree [-h] [-v] [-f] [--python PYTHON] [-a] [-l] [-u] [-w [{silence,suppress,fail}]] [-r] [-p PACKAGES] [-e PACKAGES] [-j] [--json-tree] [--graph-output OUTPUT_FORMAT] Dependency tree of the installed python packages optional arguments: -h, --help show this help message and exit -v, --version show program's version number and exit -f, --freeze Print names so as to write freeze files --python PYTHON Python to use to look for packages in it (default: where installed) -a, --all list all deps at top level -l, --local-only If in a virtualenv that has global access do not show globally installed packages -u, --user-only Only show installations in the user site dir -w [{silence,suppress,fail}], --warn [{silence,suppress,fail}] Warning control. "suppress" will show warnings but return 0 whether or not they are present. "silence" will not show warnings at all and always return 0. "fail" will show warnings and return 1 if any are present. The default is "suppress". -r, --reverse Shows the dependency tree in the reverse fashion ie. the sub- dependencies are listed with the list of packages that need them under them. -p PACKAGES, --packages PACKAGES Comma separated list of select packages to show in the output. If set, --all will be ignored. -e PACKAGES, --exclude PACKAGES Comma separated list of select packages to exclude from the output. If set, --all will be ignored. -j, --json Display dependency tree as json. This will yield "raw" output that may be used by external tools. This option overrides all other options. --json-tree Display dependency tree as json which is nested the same way as the plain text output printed by default. This option overrides all other options (except --json). --graph-output OUTPUT_FORMAT Print a dependency graph in the specified output format. Available are all formats supported by GraphViz, e.g.: dot, jpeg, pdf, png, svg

February 10, 2023 · 2 min · Peter

Cheatsheet for pkg manager

Cheatsheet for package manager go mod pip apt ubuntu 20.04 pip pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package 升级 pip 到最新的版本 (>=10.0.0) 后进行配置: pip install pip -U pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple 如果您到 pip 默认源的网络连接较差,临时使用本镜像站来升级 pip: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U apt ubuntu 20.04 # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse # 预发布软件源,不建议启用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse go mod GOPROXY=https://goproxy.io,direct ...

July 24, 2020 · 1 min · Peter

pip 离线安装

pip 离线安装 打包 注意,要在同平台打包,否则有些包不能正确安装。 在已有的环境中,一般是一个虚拟环境: pip freeze > pip-requirements.txt pip download -d pip-packages -r pip-requirements.txt,将提取的包下载到pip-packages文件夹中 安装 将pip-requirements.txt和pip-packages文件夹,拷贝到目标环境的同目录下 pip install –no-index –find-links=pip-packages -r pip-requirements.txt 参考 断网环境下一键安装 python3 离线安装包及其依赖 下载依赖 pip-download example pip install pip-download pip-download -p win_amd64 -p none-any fabric

July 22, 2020 · 1 min · Peter

pipenv

pipenv pip和virtualenv的组合,使用Pipfile来替换旧的requirements.txt方式。 documentation zhihu 参考 segmentfault 参考 安装 安装到系统常用的python版本下,mac可以使用brew安装 $ pip install pipenv 创建虚拟环境 $ pipenv install --three django 创建一个python3的虚拟环境并安装django,随机生成一个和当前文件夹名有关的虚拟环境。也可以用过--python 3.7指定python版本。 TODO, 不能指定名称吗? 进入虚拟环境 $ pipenv shell 不过就算不进入环境,pipenv install依然可以正确安装包到对应的环境。 新环境依赖 自动识别Pipfile,然后安装。 $ pipenv install 一并安装开发环境的包: $ pipenv install --dev 区别开发环境 在安装包的时候添加一个--dev选项,会分类到开发依赖。 更换源 更换Pipfile中的source-url [[source]] url = "https://mirrors.aliyun.com/pypi/simple" verify_ssl = true name = "pypi" 设置环境变量 PIPENV_PYPI_MIRROR 效果相同。类似指定–pypi-mirror选项: $ pipenv install --pypi-mirror https://mirrors.aliyun.com/pypi/simple 查看安装的包 $ pipenv graph 不仅可以看到安装包,还可以看到依赖关系。 ...

July 22, 2020 · 1 min · Peter

wheel

wheel 提供给系统组的wheel包构建,要求none-any 以oss2包为例 pip download oss2 --platform=any --abi=none --no-deps 查看setup.py中的依赖,分别用上面的命令下载,获得所有的源码包。 打包wheel,universal选项可以打包忽略平台和架构的包;如果包里面含有c extension是不支持universal的,必须是纯python实现 python .\setup.py bdist_wheel --universal 如果遇到打包错误 error: invalid command 'bdist_wheel',可以修改setup.py使用setuptools的setup方法: # from distutils.core import setup from setuptools import setup

July 22, 2020 · 1 min · Peter