简体   繁体   English

在OSX Snow Leopard上安装IPython以使用非默认的python版本(即python2.6.6 / python2.7)

[英]Installing IPython to work with a non-default python version (i.e python2.6.6/python2.7) on OSX Snow Leopard

OK guys this is tricky, and I haven't even found a suitable solution on the IPython website. 好的家伙这很棘手,我甚至都没有在IPython网站上找到合适的解决方案。

I'm working on OSX Snow Leopard. 我正在研究OSX Snow Leopard。 I've installed IPython using easy-install, plus all the additional basic add-ons: 我已经使用easy-install安装了IPython,以及所有其他基本附加组件:

$ sudo easy-install readline pexpect nose ipython

Everything worked OK and installed correctly. 一切正常,安装正确。

The problem is that IPython uses the python 2.6.1 interpreter, but I would like to use the python 2.6.6 or python 2.7. 问题是IPython使用python 2.6.1解释器,但我想使用python 2.6.6或python 2.7。 It is necessary since I'm using the "pygame" module, which only works with my python 2.6.6 installation. 这是必要的,因为我使用“pygame”模块,它只适用于我的python 2.6.6安装。

How can I do that? 我怎样才能做到这一点? Thanks in advance. 提前致谢。


Another solution: 另一种方案:

(besides the already accepeted answer, thanks for that btw.) (除了已经加入的答案,谢谢你顺便说一下。)

I just used pip to pip uninstall ipython and then sudo pip install ipython . 我只是使用pippip uninstall ipython然后sudo pip install ipython This installed it against my latest python version. 这是我最新的python版本安装它。 Thanks for the other version though! 谢谢你的其他版本! I've come to use pip for all my python installation necessities instead of easy_install as of late. 我已经开始使用pip来代替所有我的python安装必需品而不是easy_install

I just got the same problem, and I think I found a solution. 我遇到了同样的问题,我想我找到了解决方案。

After update your python to a non-default version, say 2.6.6, you must also reinstall setup-tools. 将python更新为非默认版本(例如2.6.6)后,还必须重新安装setup-tools。 To verify if your easy_install is correctly installed, type "which easy_install" to see if easy_install is under "/Library/Frameworks/Python.framework/Versions/2.6/bin/" directory, if not, it might show in "/usr/bin/", then you need to download the right version of setup-tools, for example, for 2.6.6, it's setuptools-0.6c11-py2.6.egg, and use "sh ./setuptools-0.6c11-py2.6.egg" to install it. 要验证您的easy_install是否已正确安装,请键入“which easy_install”以查看easy_install是否位于“/Library/Frameworks/Python.framework/Versions/2.6/bin/”目录下,如果没有,则可能会显示在“/ usr /”中bin /“,然后你需要下载正确版本的setup-tools,例如2.6.6,它是setuptools-0.6c11-py2.6.egg,并使用”sh ./setuptools-0.6c11-py2。 6.egg“安装它。 After all that, you need to reopen Teminal just to make all env-variables get refreshed, and then when you use "easy_install ipython", you can get the right version working with ipython. 毕竟,你需要重新打开Teminal以使所有env变量都刷新,然后当你使用“easy_install ipython”时,你可以使用ipython获得正确的版本。

It works for me, and I hope it can help you, too. 它适用于我,我希望它也可以帮助你。

调用随适当版本的Python安装的easy_install版本。

easy_install-2.7 ...

This instructions on the following link worked for me: 以下链接上的说明对我有用:

http://blog.praveengollakota.com/47430655 (do make sure to follow the easy_install step so that python2.7 will get picked up by easy_install!!) http://blog.praveengollakota.com/47430655 (确保遵循easy_install步骤,以便easy_install获取python2.7 !!)

I had to do the following additional steps to get things to work properly: 我必须执行以下额外步骤才能使事情正常运行:

1) Update ~/.profile to add the "/Library/Frameworks/Python.framework/Versions/2.7/bin" to my $PYTHONPATH and source it to make sure that the old ipython path wasn't being picked up. 1)更新〜/ .profile将“/Library/Frameworks/Python.framework/Versions/2.7/bin”添加到我的$ PYTHONPATH并获取它以确保没有拾取旧的ipython路径。

2) Do "sudo easy_install readline" to ensure the tab completions and other features of ipython work properly. 2)执行“sudo easy_install readline”以确保ipython的选项卡完成和其他功能正常工作。

(In my case, I also use pymongo, so I did have to uninstall (sudo pip uninstall pymongo) and install (sudo easy_install pymongo) to get the pymongo package to work). (在我的情况下,我也使用pymongo,所以我必须卸载(sudo pip uninstall pymongo)并安装(sudo easy_install pymongo)以使pymongo包工作)。

Hope this helps. 希望这可以帮助。

Why not see if just changing the shebang line in the python\\scripts directory works? 为什么不看看是否只更改python \\ scripts目录中的shebang行有效? There should be an IPython starter shell script there. 那里应该有一个IPython入门shell脚本。 Point it at the full path of the desired Python load and give it a whirl. 将它指向所需Python负载的完整路径并给它一个旋转。

Not sure of the full path to the scripts directory on OS X. On Windows it's at c:\\Python2x\\Scripts. 不确定OS X上脚本目录的完整路径。在Windows上,它位于c:\\ Python2x \\ Scripts。

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

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