码迷,mamicode.com
首页 > 其他好文 > 详细

# 2021-01-14 #「pip」- 模块安装程序

时间:2021-01-15 11:57:03      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:package   end   get   解决   特定   option   can   升级   none   

pip(1),用于安装和管理 Python 模块。

安装 pip 命令

How to Install Python Pip on Ubuntu 20.04 | Linuxize

################################################################################
####### pip2 on Ubuntu 20.04 LTS
################################################################################
add-apt-repository universe
apt update 
apt install python2

curl https://bootstrap.pypa.io/get-pip.py --output /tmp/get-pip.py
python2 get-pip.py

pip2 --version

修改 pip.conf 配置

Find default pip index-url - Stack Overflow
python - Updating the pip.conf file to use https - Stack Overflow

pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/

# 或者直接修改 ~/.pip/pip.conf 配置文件

修改 pip 配置,以使用阿里镜像站点

# 进行全局设置
pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/

# 只为特定安装包
pip install --index-url http://mirrors.aliyun.com/pypi/simple/ "<pkg-name>"

requirements.txt

通过 requirements.txt 文件,可以在其中保存需要安装的 Python 模块,然后使用 pip install -r requirements.txt 命令安装。

在 requirements.txt 中,为特定模块使用不同的安装选项

python - How to maintain pip install options in requirements file made by pip freeze? - Stack Overflow

pymongo==2.1.1 --install-option=‘--no_ext‘

SyntaxError: invalid syntax

CENTOS/RHEL 6 PYTHON PIP ERROR, SYNTAXERROR: INVALID SYNTAX {STR(C.VERSION) FOR C IN ALL_CANDIDATES}

问题描述

# pip search supervisor
Traceback (most recent call last):
  File "/usr/bin/pip", line 7, in <module>
    from pip._internal.cli.main import main
  File "/usr/lib/python2.6/site-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/lib/python2.6/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/lib/python2.6/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/lib/python2.6/site-packages/pip/_internal/cli/cmdoptions.py", line 107
    binary_only = FormatControl(set(), {‘:all:‘})
                                               ^
SyntaxError: invalid syntax

问题原因

you’ll need to version lock PIP when you upgrade it to 9.0.3. This is the last stable version of PIP that is compatible with Python 2.6

解决办法

我们先解决语法错误问题,使命令可用(否则执行 pip 将永远返回错误):

yum reinstall -y python-pip
pip install pip==9.0.3 

在我们的场景中,我们需要安装 Supervisor 工具,由于 CentOS 6.5 已经自带,所以直接安装即可(yum install supervisor)。

由于 CentOS 6.5 没有提供 Python 2.7 版本,因此语法无法兼容,因此我们无法将 pip 升级到 9.0.3 版本之后。
也不建议强制安装 Python 2.7 版本,因为这可能会破坏 YUM 工具,或者其他软件。
如果需要使用其他版本,建议使用虚拟环境,或者可以考虑使用 Python 3.4 版本(存在于 CentOS 6.5 仓库中)。

InsecurePlatformWarning: A true SSLContext object is not available

SSL InsecurePlatform error when using Requests package
InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately

# pip install --upgrade pip
You are using pip version 7.1.0, however version 20.1.1 is available.
You should consider upgrading via the ‘pip install --upgrade pip‘ command.
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: 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
Collecting pip
  Using cached https://files.pythonhosted.org/packages/43/84/23ed6a1796480a6f1a2d38f2802901d078266bda38388954d01d3f2e821d/pip-20.1.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 7.1.0
    Uninstalling pip-7.1.0:
      Successfully uninstalled pip-7.1.0
Successfully installed pip-20.1.1

参考文献


# 2021-01-14 #「pip」- 模块安装程序

标签:package   end   get   解决   特定   option   can   升级   none   

原文地址:https://www.cnblogs.com/k4nz/p/14278734.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!