Python troubleshooting: ImportError: cannot import

2019-01-28 17:08发布

I'm facing a problem with Package Installation, pip. I am using Python 3.6.

When I try to install a package with pip I receive the following message in the cmd.

*C:\Python36\Scripts>pip intstall --user httpie
Traceback (most recent call last):
  File "c:\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python36\Scripts\pip.exe\__main__.py", line 5, in <module>
ImportError: cannot import name 'main'*

It happened when I upgraded the pip, before it worked. I tried to uninstal the Python and installed this again but it does not work. I cannot find the solution, any ideas?

3条回答
淡お忘
2楼-- · 2019-01-28 17:25

Firstly if you have installed pip then remove it by deleting the folder of pip inside python directory. Then install pip by this command:

$ sudo easy_install pip

This will install older version, you can download newer version after 10th when it will come.

查看更多
放荡不羁爱自由
3楼-- · 2019-01-28 17:32

I fixed it. I deleted the folder with pip as you said. Because I work in Windows 10, I downloaded the get-pip.py from https://pip.pypa.io/en/stable/installing/ and I run it.

查看更多
仙女界的扛把子
4楼-- · 2019-01-28 17:33

You can also downgrade to pip 9.x using

python -m pip install -U "pip<10"
查看更多
登录 后发表回答