尝试使用configparser安装pip报错

Trying to install pip error with configparser

我正在尝试安装 pip,但在使用 configparser 时遇到了一些问题。不知何故,import configparser 指向 python 的系统版本,python 2.7 而不是 python 3.5

>> pip install -U pip
Traceback (most recent call last):
  File "/Users/../anaconda3/bin/pip", line 9, in <module>
    load_entry_point('pip==8.1.2', 'console_scripts', 'pip')()
  File "/Users/../anaconda3/lib/python3.5/site-packages/setuptools-23.0.0-py3.5.egg/pkg_resources/__init__.py", line 542, in load_entry_point
  File "/Users/../anaconda3/lib/python3.5/site-packages/setuptools-23.0.0-py3.5.egg/pkg_resources/__init__.py", line 2569, in load_entry_point
  File "/Users/../anaconda3/lib/python3.5/site-packages/setuptools-23.0.0-py3.5.egg/pkg_resources/__init__.py", line 2229, in load
  File "/Users/../anaconda3/lib/python3.5/site-packages/setuptools-23.0.0-py3.5.egg/pkg_resources/__init__.py", line 2235, in resolve
  File "/Users/../anaconda3/lib/python3.5/site-packages/pip/__init__.py", line 14, in <module>
    from pip.utils import get_installed_distributions, get_prog
  File "/Users/../anaconda3/lib/python3.5/site-packages/pip/utils/__init__.py", line 23, in <module>
    from pip.locations import (
  File "/Users/../anaconda3/lib/python3.5/site-packages/pip/locations.py", line 10, in <module>
    from distutils.command.install import install, SCHEME_KEYS  # noqa
  File "/Users../anaconda3/lib/python3.5/distutils/command/install.py", line 9, in <module>
    from distutils.core import Command
  File "/Users/../anaconda3/lib/python3.5/distutils/core.py", line 18, in <module>
    from distutils.config import PyPIRCCommand
  File "/Users/../anaconda3/lib/python3.5/distutils/config.py", line 7, in <module>
    from configparser import RawConfigParser
  File "/Library/Python/2.7/site-packages/configparser.py", line 12, in <module>
    from backports.configparser import (

我假设您根据命令使用 Linux OS。 尝试使用 apt-get:

安装
apt-get install python-pip

如果不是以 root 身份登录,您必须知道 root 密码:

sudo apt-get install python-pip

我使用相同的命令在 Raspberry Pi 和 Ubuntu 16

上安装它

修改 PYTHONPATH 使 python 3.x 包路径在 2.x 包路径

之前