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

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. 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:

Installed python through homebrew and then used pip to install virtualenv

Installed python through https://www.python.org and then used pip to install virtualenv

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

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.

Removed python 2.7 by using the post in here

Removed the homebrew installed version

Manually installed virtualenv following the instructions from here:

curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-13.1.2.tar.gz

tar xvfz virtualenv-13.1.2.tar.gz

cd virtualenv-13.1.2

sudo python setup.py install

Manaully install pip through 7:

curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python2.7

PIP was still broken after all this:

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:

source venv/bin/activate

2- Forces pip to install in the right destination:

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.

How I got it to work:

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

1 - Removed python 2.7 by using the post in here

2 - Removed the homebrew python installed version

brew uninstall python

3- Reinstall your Xcode command tools:

sudo xcode-select --install

4- Upgrade homebrew and reinstall python through homebrew:

brew update && brew reinstall python

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值