python基础篇12-下载三方库

安装psycopg2 4 方式1:pip  install  psycopg2-binary
 5 方式2:pip  install  psycopg2
 6 
 7 Command python setup.py egg_info failed with error code 1
 8 原因在于本地需要安装PostgreSQL的app文件,所以先安装下 brew install postgresql.
 9 安装时报错,信息如下:
10   curl: (22) The requested URL returned error: 404 Not Found
11   Error: Failed to download resource “openssl”
12   Download failed: https://raw.githubusercontent.com/DomT4/LibreMirror/master/OpenSSL/openssl-1.0.2.tar.gz
13 
14 OpenSSL的版本太低,先升级brew的版本brew update.
15   再次执行brew install postgrelsql
16 需要import pg_config到环境变量中:export PATH=$PATH:/apps/svr/homebrew/Cellar/postgresql/9.4.5_2/bin/
18 
19 安装完成后再安装: pip install psycopg2
依赖管理方式1:
 1 首先,在项目中分析出所有依赖的库
 2   pip freeze > requirements.txt
3
下载指定文件中相关依赖:pip install -r requirements.txt
 4 将所有包下载到DIR这个目录中:
 5   $ pip download -d DIR -r requirements.txt
 6   $ pip wheel -w DIR -r requirements.txt
 7 
 8 这两条命令的区别在于wheel 方式下载会将下载的包放入wheel 缓存,但缺点是wheel 不可以下载源码包
 9 download 命令会查看wheel缓存,然后再去PyPI下载库,但download命令下载的包不会进入wheel缓存,download 的优点是可以下载源码包,需要注意,使用wheel 方式安装可能会报错,因为有些包是源码包,不能被打包成wheel 格式
11 download 方法下载的包,不会对依赖性进行检查,这意味着,如果下载 Flask-PyMongo 这个包,只会下载该包,而不会下载 pymongo,经试验发现,download 适合补充wheel不可下载的包,两者搭配使用,才能将requirements文件的库完整的下载
12 注意: 如果只使用download 方法下载,很有可能安装时候会报错

posted @ 2020-01-09 10:29  为你编程  阅读(247)  评论(0编辑  收藏  举报