[Solved] From pip._internal import cmdoptions ImportError: cannot import name SourceDistribution

Background of the problem

When changing 32-bit Python to 64 bit, this problem suddenly appeared. I was so confused that PIP list PIP install couldn’t be used. I made a mistake

first execute the command: Python - M ensurepip -- default PIP
Download get-pip.py at https://bootstrap.pypa.io/get-pip.py After entering, it is directly code, so you need to create a new get-pip.py file, copy and paste it, and finally enter the directory where the get-pip.py file is located from the command line CMD, Execute command: Python get pip. Py
note that permission error may be reported when executing this step. At this time, Python get pip. Py -- user should be executed
Let’s go on

How to enter the directory where the get-pip.py file is located, you can follow the steps below in general windows

      1. search for CMD in the lower left corner, enter the drive letter where the file is located, for example, my get pip.py file is in

D: , then enter CMD, enter D: and then copy the directory of the file, paste enter, my file is D: + enter

After checking, it seems to say that PIP version 20. Has this problem, but PIP version 21. Is gone. Maybe there is a bug in the previous version

Read More: