修复python2 pip
Recently when trying to run a Python script on my Mac, I faced an import error for a specific Python module:
最近,当尝试在Mac上运行Python脚本时,我遇到了特定Python模块的导入错误:
错误 (The error)
I thought that the solution would be rather easy; I could just use Python’s package installer, pip
, and install boto.sts
. However, when I tried running $ pip install boto
, I received a frustrating and confusing error:
我认为解决方案会很容易。 我可以只使用Python的软件包安装程序pip
并安装boto.sts
。 但是,当我尝试运行$ pip install boto
,收到一个令人沮丧且令人困惑的错误:
“Okay,” I thought. “I probably just need to go on a little pip
journey and install md5
.” No such luck. Same error — this, to me, indicated more of an issue with pip
than anything.
“好吧,”我想。 “我可能只需要进行一些小 pip
并安装 md5
。” 没有这种运气。 同样的错误-对我来说,这表明pip
的问题比什么都重要。
我的解决方案 (My solution)
Note that your mileage may vary here; I just wanted to document what worked for me since I just wanted any resources regarding this issue when I was looking it up.
请注意,您的里程可能会有所不同; 我只是想记录一下对我有用的东西,因为当我查找该问题时,我只想要有关该问题的任何资源。
Firstly, my Python version, which I found out when I ran $ python --version
, was 2.7.16.
首先,我运行$ python --version
时发现的Python版本是2.7.16 。
使用Homebrew卸载Python 2 (Use Homebrew to uninstall Python 2)
Don’t worry. You’ll fall back to your Mac-default Python version. In my case, it was 2.7.10. I don’t want to get too much into hypotheses here, but it’s possible at some point my machine had a newer version of Python installed which had issues with pip
.
不用担心 您将回到Mac默认的Python版本。 就我而言,是2.7.10 。 我不想在这里过多地进行假设,但是有可能在我的机器上安装了较新版本的Python,而pip
出现了问题。
就这么简单 (It was that simple)
That was all that was needed for me. I was able to run my script (using pip
to install boto
and a few other modules I didn’t have yet) just fine after running that one command.
这就是我所需要的。 运行该命令后,我能够运行我的脚本(使用pip
安装boto
和我尚未使用的其他一些模块)。
It was a tremendous relief. Of course, this worked for my specific Python installation and for my environment, but I wanted to add to the results for any other stressed developers looking for a solution to this unintuitive issue.
这是极大的解脱。 当然,这对于我特定的Python安装和我的环境都有效,但是我想为其他寻求解决此直观问题的解决方案的压力大的开发人员增加结果。
翻译自: https://medium.com/dev-genius/how-to-fix-md5-importerror-with-python-2-and-pip-cfe389dc24eb
修复python2 pip