由于版本冲突,无法在anaconda3基本环境中运行pip

时间:2019-10-16 08:43:30

标签: python python-3.x pip anaconda multiple-versions

我想使用pip在anaconda3基本环境中安装软件包,但看起来anaconda pip软件包与我安装的python 3.7 pip之间存在冲突。

我有三个pip.exe文件:

(base) C:\Users\DELL>where pip
C:\Users\DELL\Anaconda3\Scripts\pip.exe
C:\Users\DELL\AppData\Local\Programs\Python\Python37-32\Scripts\pip.exe
C:\Users\DELL\AppData\Local\Programs\Python\Python36-32\Scripts\pip.exe

但是我什至无法在anaconda提示符下运行pip -V,但出现此错误:

Traceback (most recent call last):
  File "C:\Users\DELL\Anaconda3\Scripts\pip-script.py", line 6, in <module>
    from pip._internal import main
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pip\_internal\__init__.py", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pip\_internal\cli\autocompletion.py", line 8, in <
module>
    from pip._internal.cli.main_parser import create_main_parser
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pip\_internal\cli\main_parser.py", line 11, in <mo
dule>
    from pip._internal.commands import (
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pip\_internal\commands\__init__.py", line 9, in <m
odule>
    from pip._internal.commands.download import DownloadCommand
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pip\_internal\commands\download.py", line 10, in <
module>
    from pip._internal.operations.prepare import RequirementPreparer
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pip\_internal\operations\prepare.py", line 9, in <
module>
    from pip._internal.distributions import (
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pip\_internal\distributions\__init__.py", line 1,
in <module>
    from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source' (C:\U
sers\DELL\Anaconda3\lib\site-packages\pip\_internal\distributions\source\__init__.py)

我使用pip install <package_name>从Windows cmd安装了一个软件包,它运行良好,但是当我在Windows cmd中使用python -m pip install --upgrade pippython -m pip install <package_name>时,我得到了类似的错误:

Traceback (most recent call last):
  File "C:\Users\DELL\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\DELL\Anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pip\__main__.py", line 16, in <module>
    from pip._internal import main as _main  # isort:skip # noqa
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pip\_internal\__init__.py", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pip\_internal\cli\autocompletion.py", line 8, in <
module>
    from pip._internal.cli.main_parser import create_main_parser
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pip\_internal\cli\main_parser.py", line 11, in <mo
dule>
    from pip._internal.commands import (
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pip\_internal\commands\__init__.py", line 9, in <m
odule>
    from pip._internal.commands.download import DownloadCommand
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pip\_internal\commands\download.py", line 10, in <
module>
    from pip._internal.operations.prepare import RequirementPreparer
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pip\_internal\operations\prepare.py", line 9, in <
module>
    from pip._internal.distributions import (
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pip\_internal\distributions\__init__.py", line 1,
in <module>
    from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source' (C:\U
sers\DELL\Anaconda3\lib\site-packages\pip\_internal\distributions\source\__init__.py)

请问如何解决此冲突?

0 个答案:

没有答案