0

I try to install scipy on my mac 10.6.8 but always have problem with it. I've installed ipython (sudo /usr/bin/easy_install-2.6 ipython) and numpy (python setup.py build/install), but when I installed scipy by the same way, I got always this error message:

RuntimeError: Running cythonize failed!

Could someone tell me how to solve this problem?

MattDMo
  • 100,794
  • 21
  • 241
  • 231
Lilianna
  • 337
  • 3
  • 12
  • possible duplicate of [build scipy error cythonize failed](http://stackoverflow.com/questions/15175135/build-scipy-error-cythonize-failed) – Sergiu Dumitriu Mar 16 '13 at 13:08

1 Answers1

1

Have you tried using the binaries provided for OSX? That should ensure everything works.

EDIT

The easiest way I've found to keep package dependencies under control is to use MacPorts as much as possible because unlike Homebrew, the packages are designed to work together and dependencies are (almost always) automagically installed when you try to install something.

So, first, install MacPorts using the installer for Snow Leopard. Choose the option to install ports in a unique directory like /opt/local, so they don't conflict with whatever built-in versions the OS depends on. Also, ensure that /opt/local/bin and /opt/local/sbin are added to your $PATH before the system directories like /usr/bin, /bin, /sbin etc. so that when you run python from the command prompt you get the version you want. Your ~/.profile should have something like export PATH="/opt/local/bin:/opt/local/sbin:$PATH as its last line.

After MacPorts has been installed, you may want to restart just for fun to ensure that all of your environment variable are set up properly. Start Terminal.app (or your favorite replacement) and enter which port, which should return /opt/local/bin/port if everything worked correctly. Next, run sudo port selfupdate just to make sure everything is synced properly. Once that is done, we can install python and some modules. port allows you to pass a list of ports to be installed, so a command like sudo port install foo bar baz will install the latest versions of the foo, bar, and baz ports, along with any dependencies they may require, in the correct order. Some ports have binary distributions, and others are compiled as needed, so the first time you run it there may be a lot of dependencies to install. A nice feature of MacPorts is that you can have multiple versions of some packages installed at the same time, and you can switch between them if needed. Also, if port search is giving too many results, the online search engine can help you find what you're looking for.

To get a decent IPython-based Python 2 development environment going, you'll need the following:

  • python27
  • py27-ipython
  • py27-numpy
  • py27-scipy
  • py27-matplotlib (if you like drawing pretty pictures, but mainly so you can get pylab)
  • py27-pandas (DataFrames are your friend!)
  • and perhaps py27-pyqt4 if you run ipython via the qtconsole option

I'd also install py-pip and py27-distribute so you can install modules on your own if there is no MacPort version.

Finally, if you're a forward-looking person and want to use numpy et al. on Python 3, MacPorts has you covered! There are py32- and py33-based versions of all of the above packages except scipy, which is only py32 for now. However, I was able to install it just fine with pip, although I have a whole bunch of other devel tools on my machine, and I'm running 10.8.2, so YMMV.

Good luck!

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • yes I've tried it, but it turns out always the error message when I installed "scipy 0.11.0 can't be installed on this disk. scipy requires python.org Python 2.6 to install". But I've already installed the python 2.6.1 – Lilianna Mar 16 '13 at 14:44
  • @user2177001 - see my much-revised and expanded comment above, and let me know if you have further questions. – MattDMo Mar 16 '13 at 17:28
  • Thank you very much! I've installed MacPorts and it seems working well. But always can't install scipy. My steps were: "sudo port selfupdate" then "sudo port install python27" and "sudo port install py27-ipython py27-numpy py27-scipy", the response I got is"---> Computing dependencies for py27-scipy ---> Cleaning py27-scipy ---> Scanning binaries for linking errors: 100.0% ---> No broken files found. " Then I tried to start ipython and import scipy, but it said "ImportError: No module named scipy". – Lilianna Mar 16 '13 at 19:52
  • @Lilianna - make sure you are using the MacPorts version of ipython, and that your `$PATH` is set to search in the `/opt/local` directories before anywhere else. Also, look in `/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/site-packages` and see if there is a scipy folder there, along with ipython, numpy, and the rest. – MattDMo Mar 16 '13 at 21:14
  • sorry, that should be `/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages` – MattDMo Mar 16 '13 at 22:03
  • Thank you!! yes there are IPython, ipython-0.13.1-py2.7.egg-info, numpy, numpy-1.6.2-py2.7.egg-info, scipy, scipy-0.11.0-py2.7.egg-info and many other things... and my $PATH is /opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/texbin:/usr/X11/bin – Lilianna Mar 16 '13 at 22:33
  • make sure you're running the right IPython - try running `/opt/local/bin/ipython` directly, or even better, forget IPython for now and run `/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python` and try an `import scipy` statement in the interpreter – MattDMo Mar 16 '13 at 23:02
  • it told "-bash: cd: python: Not a directory" when I ran /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python – Lilianna Mar 17 '13 at 09:45
  • don't `cd`, just type `/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python` directly at the command prompt and hit `Enter` – MattDMo Mar 17 '13 at 16:38
  • Yeah I can import scipy now!!! Thank you so so so much!!! Just how can I move python to the right place so that I could start it wherever I am? Also, I need to install asciidata, is it "sudo port install py27-asciidata"? – Lilianna Mar 17 '13 at 19:47
  • Great, we're almost there! Go to the `/opt/local/bin` directory in Terminal and enter `ls -Fal *python*` to see what you have there, and if they are symlinks what they point to. In particular, check to see that `ipython` exists and points to `/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/ipython`. If it doesn't exist, create it with `ln -s /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/ipython ipython`. Next, check to see that `opt/local/bin/python` exists, and is a symlink either to a `python2` file in the same directory, or (see next comment) – MattDMo Mar 18 '13 at 02:03
  • to a file in the `/opt/local/Library/.../2.7/bin` directory. If **it** doesn't exist, create it with `ln -s /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python python`. Now, you should be all set to enter `ipython` or `python` at the command prompt and have the desired program start. To install `asciidata` you'll need to use `pip`, as there is no MacPorts version. Install it (`sudo port install py27-pip`), create a symlink from `/opt/local/bin/pip-2.7` to `/opt/local/bin/pip` if one doesn't exist, then run `sudo pip install asciidata` and everything should work OK. – MattDMo Mar 18 '13 at 02:15
  • Finally, you may wish to add `/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin` to your `$PATH` just so you're not constantly creating symlinks every time a new python utility is installed. I'd put it first, and then you wouldn't even really have to worry about creating the symlinks to `ipython`, `python`, and `pip`, although knowing how to create symlinks (`ln -s ExistingFile NewSymlink`) is very useful. To remove them, just use `rm` or `sudo rm` as appropriate. Good luck! – MattDMo Mar 18 '13 at 02:19
  • Thank you!!! I'm going for one week's observation without my laptop, I'll try this when I come back! Thank you very much and have a nice week!!! – Lilianna Mar 18 '13 at 07:06
  • 1) ipython doesn't exist, there is only ipython-2.7 pointing to /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/ipython. When I start a ipython-2.7 from the terminal, everything works well, I can have scipy in this way, but if I start simply a python, I don't have scipy. I created ln -s /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/ipython python it didn't change anything. – Lilianna Mar 24 '13 at 16:05
  • 2) opt/local/bin/python doesn't exist neither, only python2@ -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2 I tried to create ln -s /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python python from /opt/local/bin, but it returns "ln: python: Permission denied" 3) pip has been installed, but impossible to create link from the terminal with "ln -s /opt/local/bin/pip-2.7 /opt/local/bin/pip" (ln: /opt/local/bin/pip: Permission denied) – Lilianna Mar 24 '13 at 16:07
  • @MattDMo-1) ipython doesn't exist, there is only ipython-2.7 pointing to /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/ipython. When I start a ipython-2.7 from the terminal, everything works well, I can have scipy in this way, but if I start simply a python, I don't have scipy. I created ln -s /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/ipython python it didn't change anything. – Lilianna Mar 25 '13 at 12:12
  • 2) opt/local/bin/python doesn't exist neither, only python2@ -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2 I tried to create ln -s /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python python from /opt/local/bin, but it returns "ln: python: Permission denied" 3) pip has been installed, but impossible to create link from the terminal with "ln -s /opt/local/bin/pip-2.7 /opt/local/bin/pip" (ln: /opt/local/bin/pip: Permission denied) – Lilianna Mar 25 '13 at 12:13