qianlei90 / Blog

那些该死的文字呦
https://qianlei.notion.site
103 stars 20 forks source link

pip问题集锦 #31

Open qianlei90 opened 7 years ago

qianlei90 commented 7 years ago

pip问题集锦

Tags: 印象笔记 Python

[toc]


1. 出现警告提示

pip install或者pip search时出现如下提示:

/home/hoh0/.pyenv/versions/2.7/envs/yihe.io/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/home/hoh0/.pyenv/versions/2.7/envs/yihe.io/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning

需要在当前的虚拟环境中安装以下包:

pip install pyopenssl ndg-httpsclient pyasn1

可能需要在系统中安装以下包(未测试):

sudo yum install libffi-dev libssl-dev

2. 使用第三方pip源

pip install flask --trusted-host pypi.jcing.com --index http://username:password@pypi.jcing.com/simple

--trusted-host: 信任该url,即使不使用https协议 --index: 安装包时使用的源,如果是公开的pip源,可以不用加username:password

3. 环境变量

pip会把以PIP_开头的环境变量当做配置,所以如果有自定义的环境变量要和pip组合使用,不要以PIP_来命名自己的环境变量。如pip的用户名、密码要从环境变量读取,环境变量取名为PYTHON_PIP_USERPYTHON_USER_PASSWORD,不要取名PIP_USERPIP_PASSWORD,会提示ValueError: invalid truth value ...

- 完 - 2017/03/14