简体   繁体   English

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

[英]How to fix broken python 2.7.11 after OSx updates

What happened:发生了什么:

After an OSx update and installing a new version of python 2.7 my virtualevn environment completely broke and I struggled in fixing it.在 OSx 更新并安装新版本的python 2.7我的virtualevn环境完全崩溃了,我努力修复它。 I wasn't sure what caused it and went through a whole set of things that I did and read initially that didn't work are listed below.我不知道什么原因引起的,并通过一整套的东西,我没有和最初读的是没有工作,下面列出了去了。 What solved my problem is provided in the answer section.答案部分提供了解决我问题的方法。

What didn't work to fix virtualenv command not found:找不到修复virtualenv命令无效的方法:

  • Installed python through homebrew and then used pip to install virtualenv通过homebrew安装python,然后用pip安装virtualenv
  • Installed python through https://www.python.org and then used pip to install 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 virtualenv-command-not-found
  2. virtualenv-workon-command-not-found 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 here neither here helped.在此之后所有的人创造一个虚拟的环境后,我的点子还是在主蟒蛇文件夹安装的软件包,而不是线程的虚拟环境和非下安装它们的位置既不是在这里帮助。 My solution to that was to run pip under my virtual env with the following options: 1- Activate the virtual environment so that $VIRTUAL_ENV is 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.这个问题的答案中提供了一些严重损坏和修复我的开发环境的最佳方法。

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 here and 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    

After doing brew upgrade python my system python was broken and was throwing fits about virtualenvwrapper.sh, as well as my pip command was just suddenly missing.在执行brew upgrade python我的系统 python 坏了,并且对 virtualenvwrapper.sh 产生了影响,而且我的pip命令突然丢失了。 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 virtualenvwrapper and things seem to work.我去 python.org 下载了 python 2.7.13 安装程序,运行它,我现在有 python 2.7.13,pip,并且可以运行pip install virtualenvwrapper并且事情似乎工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM