How to Install rpy2 on Mac OS X

依然范特西╮ 提交于 2019-12-04 06:47:48

easy_install and rpy2 work fine together (just did it) but you need to have easy_install in sync with your specific python version. This comes down to controlling your $PATH and $PYTHONPATH environment variables so that the first Python directory that appears is the version you want and also has the easy_install version you want. Do not try to solve this by taking out the factory installed version of Python.

You set your path variables in your home directory. If you are using the default bash shell, check .bash_profile for

$ echo $PYTHONPATH /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/

which will tell you where and in what order installed packages are searched for

and

$ echo $PATH

/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:

Rather than giving a recipe for how to set these if needed, I encourage you to consult the usual sources because a little knowledge is dangerous and rendering the shell inoperative by reasonable, but wrong, guesses is a real danger.

First check that you installed rpy2 successfully. Look in /opt/local/var/macports/software for anything with rpy2 in the title. It maybe called py26-rpy depending on the version of Python you are running.

If you see that then you just need to use the right path to Python .. check the default location of Python like this:

which python

This will return the location of the first Python found and will probably say /usr/bin/python but you should use the version that rpy2 was compiled against.. which lives in /opt/local/bin.

Try:

/opt/local/bin/python2.6

then:

import rpy2
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!