简体   繁体   English

OS X 10.8:修复严重破坏的Python安装,路径变量,模块

[英]OS X 10.8: Repairing badly broken Python install, path vars, modules

So sorry for posting yet another of these types of questions, I've looked extensively and can't find an answer. 很抱歉发布了这些类型的问题,我看了很多,但找不到答案。

I'm a Python nub, and have only a loose grasp of Unix. 我是一个Python小组,只是对Unix的松散掌握。

I specifically need to develop in Python2.5. 我特别需要在Python2.5中开发。 I also need access to AppKit. 我还需要访问AppKit。 I'd installed Python2.5 via the universal installer along with the libraries I needed. 我通过通用安装程序和我需要的库安装了Python2.5。 At the time, the default OS install, 2.7, was able to import AppKit. 当时,默认的OS安装2.7能够导入AppKit。 Python2.5, meanwhile, could not. 同时,Python2.5不能。 I found this tutorial for replacing the native install of Python, and thought that if I followed it to the letter but for switching out the 2.7 install for 2.5, everything would be swell. 我发现这个教程用于替换Python的本机安装,并认为如果我按照它来执行,但是为了切换2.5安装2.5,一切都会膨胀。

After following the tutorial, my native Python is indeed 2.5. 在学习完本教程后,我的原生Python确实是2.5。 However, AppKit, which continues to be installed where it previously had been working for the native Python, still cannot be imported (ie. "no module named AppKit"). 但是,仍然无法导入AppKit,它继续安装在以前用于本机Python的地方(即“没有名为AppKit的模块”)。

  • Xcode is v.4.6.1 and CL tools are installed Xcode是v.4.6.1并安装了CL工具
  • from bash, which python returns /usr/bin/python 来自bash, which python返回/usr/bin/python
  • My primary install is at: /System/Library/Frameworks/Python.framework with symbolic links to /Library/Frameworks/Python.framework . 我的主要安装位于: /System/Library/Frameworks/Python.framework带有指向/Library/Frameworks/Python.framework符号链接。 The binaries are likewise linked; 二进制同样联系在一起; usr/bin/python (and pythonw, python-config, pydoc) are all symlinked to /usr/local/bin . usr/bin/python (和pythonw,python-config,pydoc)都符号链接到/usr/local/bin
  • I've deleted smtpd.py in every location I'd found it 我已经在我发现它的每个位置删除了smtpd.py.
  • I've left easy_install (and easy_install-2.5/6/7) in both /usr/bin and /usr/local/bin because I've never used easy_install and didn't know either way what to do with it. 我在/usr/bin/usr/local/bin都留下了easy_install(和easy_install-2.5 / 6/7),因为我从未使用过easy_install,也不知道如何处理它。

I'm perfectly aware of how profoundly I've messed everything up. 我完全清楚我已经把事情搞得一团糟。 Can anyone please tell me what I need to be doing to get things back in order? 任何人都可以告诉我我需要做些什么才能恢复原状?

UPDATE: Following the comments below, I did indeed end up re-installing Mountain Lion. 更新:根据以下评论,我确实最终重新安装了Mountain Lion。 Couldn't have been less painless; 不可能不那么无痛; I had indeed correctly installed AppKit, and as soon as the native Python was reinstalled I was able to work immediately. 我确实正确安装了AppKit,并且一旦重新安装本机Python,我就能立即工作。

It seems you've had a difficult day. 看来你有一个艰难的一天。 Let me give you some guidance: 我来给你一些指导:

  • It is generally a bad idea to follow random instructions from the internet when they don't specifically give you the instructions to revert to the original state. 当他们没有特别向您提供恢复到原始状态的指示时,通常从互联网上遵循随机指令通常是个坏主意。 "Go ahead and rm -rf something from /usr/bin" is a red flag. “来吧,来自/ usr / bin的rm -rf是一个红旗。 Experienced admins always move it out of the way, rename it, and know that removing is always a bad idea. 有经验的管理员总是把它移开,重命名,并知道删除总是一个坏主意。
  • Having to run multiple versions of Python and multiple libraries inside each of the versions installed is a standard problem with proven and tested solutions. 必须在安装的每个版本中运行多个版本的Python和多个库,这是经过验证和测试的解决方案的标准问题。 Don't remove python installations much less the default one. 不要删除python安装,更不要删除默认安装。 Learn how to use virtualenv-burrito . 了解如何使用virtualenv-burrito Learn how to pip install stuff into your virtualenvs. 了解如何将安装内容添加到您的virtualenvs中。 Keep a virtualenv for each project you work on. 为您工作的每个项目保留一个virtualenv。 Learn how to define and keep updated a requirements.txt file for each project you work on. 了解如何为您处理的每个项目定义并更新requirements.txt文件。
  • Once you understand all of this (if you don't understand you'll just repeat the same stuff). 一旦你理解了这一切(如果你不明白,你只会重复相同的东西)。 Now to solve your problem, I would revert to a point 24h ago using time machine, and then move ahead doing things the right way. 现在要解决你的问题,我会在24小时前使用时间机器恢复到一个点,然后以正确的方式前进。

Replacing the default Python is a really really really bad idea ( Remove preinstalled python from Mac OSX 10.8 , For real, too many installations of Python on OSX Mountain Lion ) 替换默认的Python是一个非常非常糟糕的主意( 从Mac OSX 10.8中删除预安装的python对于OSX Mountain Lion上的太多Python安装

You should try to rollback your machine by whatever means you can ( carlosdc suggested timemachine - that would be a great option if you have a snapshot ). 您应该尝试以任何方式回滚您的机器(carlosdc建议使用timemachine - 如果您有快照,这将是一个很好的选择)。

You can use virtualenv to create custom environments 您可以使用virtualenv来创建自定义环境

You can also use shell scripts and your user's .profile/.bash to specify which Python version should be prioritized. 您还可以使用shell脚本和用户的.profile / .bash来指定应优先考虑哪个Python版本。

I had that problem too and fixed it just installing python again, downloading it from the official website 我也有这个问题并修复它只是再次安装python,从官方网站下载

ps: my OS is el capitan ps:我的操作系统是el capitan

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

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