OSx 更新后如何修复损坏的 python 2.7.11

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34303294/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 14:47:14  来源:igfitidea点击:

How to fix broken python 2.7.11 after OSx updates

pythonmacospython-2.7osx-yosemiteosx-elcapitan

提问by AmirHd

What happened:

发生了什么:

After an OSx update and installing a new version of python 2.7my virtualevnenvironment completely broke and I struggled in fixing it. I wasn't sure what caused it and went through a whole set of things that I did and read initially that didn't workare listed below. What solved my problem is provided in the answer section.

在 OSx 更新并安装新版本的环境后,python 2.7我的virtualevn环境完全崩溃了,我努力修复它。我不知道什么原因引起的,并通过一整套的东西,我没有和最初读到了没有工作如下所示。答案部分提供了解决我问题的方法。

What didn't work to fix virtualenvcommand not found:

无法修复virtualenv找不到命令的方法:

  • Installed python through homebrew and then used pip to install virtualenv
  • Installed python through https://www.python.organd then used pip to install virtualenv
  • 通过homebrew安装python,然后用pip安装virtualenv
  • 通过https://www.python.org安装python ,然后用pip安装virtualenv

Related questions that helped me but did not provide the solution to my problem:

对我有帮助但没有为我的问题提供解决方案的相关问题:

  1. virtualenv-command-not-found
  2. virtualenv-workon-command-not-found
  1. virtualenv-command-not-found
  2. virtualenv-workon-command-not-found

Complete manual recovery I went through (What not to do!):

我经历了完整的手动恢复(不该做什么!):

This didn't completely solved my problem. It is just to give you an idea of what steps I went through before I found the correct way to fix my python dev environment on my OSx.

这并没有完全解决我的问题。这只是为了让您了解在我找到在 OSx 上修复 python 开发环境的正确方法之前我经历了哪些步骤。

PIP was still broken after all this:

在这一切之后,PIP 仍然被打破:

After all this after creating a virtual environment my pip still installed the packages in the main python folder instead of installing them under the virtual environment and non of the threads hereneither herehelped. My solution to that was to run pip under my virtual env with the following options: 1- Activate the virtual environment so that $VIRTUAL_ENVis set:

在此之后所有的人创造一个虚拟的环境后,我的点子还是在主蟒蛇文件夹安装的软件包,而不是线程的虚拟环境和非下安装它们的位置既不是在这里帮助。我的解决方案是使用以下选项在我的虚拟环境下运行 pip: 1- 激活虚拟环境,以便$VIRTUAL_ENV设置:

source venv/bin/activate

2- Forces pip to install in the right destination:

2- 强制 pip 安装在正确的目的地:

pip install --target=$VIRTUAL_ENV/lib/python2.7/site-packages   

Summary

概括

Something was badly broken and best way I fix my dev environment is provided in the answer to this question.

这个问题的答案中提供了一些严重损坏和修复我的开发环境的最佳方法。

采纳答案by AmirHd

The reason

原因

In my case was an OSx upgrade that affected my homebrew and after upgrading to python 2.7.11 is didn't install it properly.

就我而言,OSx 升级影响了我的自制软件,并且在升级到 python 2.7.11 后没有正确安装它。

How I got it to work:

我是如何让它工作的:

I found steps 3 and 4 in a thread hereand many thanks to https://github.com/baronomasia.

我在这里的一个线程中找到了第 3 步和第 4 步,非常感谢https://github.com/baronomasia

1 - Removed python 2.7 by using the post in here

1 - 使用此处的帖子删除了 python 2.7

2 - Removed the homebrew python installed version

2 - 删除了 homebrew python 安装版本

brew uninstall python

3- Reinstall your Xcode command tools:

3- 重新安装您的 Xcode 命令工具:

sudo xcode-select --install

4- Upgrade homebrew and reinstall python through homebrew:

4-升级自制软件并通过自制软件重新安装python:

brew update && brew reinstall python    

回答by nackjicholson

After doing brew upgrade pythonmy system python was broken and was throwing fits about virtualenvwrapper.sh, as well as my pipcommand was just suddenly missing. I went to python.org and downloaded the python 2.7.13 installer, ran it, I now have python 2.7.13, pip, and can run pip install virtualenvwrapperand things seem to work.

完成后,brew upgrade python我的系统 python 坏了,并且对 virtualenvwrapper.sh 产生了影响,而且我的pip命令突然丢失了。我去 python.org 下载了 python 2.7.13 安装程序,运行它,我现在有 python 2.7.13,pip,可以运行pip install virtualenvwrapper,一切似乎正常。

Homebrew is an awful, awful, tool.

Homebrew 是一个糟糕的、糟糕的工具。