question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Installation on OS X with Homebrew script error

See original GitHub issue

The installation seems to succeed, but there seems to be a problem when the tests are run (or when I go into python, trying to load anything like from qutip import * gives an error.

The script gives the following error (which can be reproduced by just running import qutip.testing as qt in python):

[. . .]
Successfully installed qutip-3.1.0
Running QuTiP unit tests
/Users/justin/.pyxbld/temp.macosx-10.10-x86_64-2.7/pyrex/qutip/cy/spmatfuncs.c:250:10: fatal error: 'numpy/arrayobject.h' file not found
#include "numpy/arrayobject.h"
         ^
1 error generated.
/Users/justin/.pyxbld/temp.macosx-10.10-x86_64-2.7/pyrex/qutip/cy/spmatfuncs.c:250:10: fatal error: 'numpy/arrayobject.h' file not found
#include "numpy/arrayobject.h"
         ^
1 error generated.
/Users/justin/.pyxbld/temp.macosx-10.10-x86_64-2.7/pyrex/qutip/cy/spmatfuncs.c:250:10: fatal error: 'numpy/arrayobject.h' file not found
#include "numpy/arrayobject.h"
         ^
1 error generated.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/qutip/__init__.py", line 213, in <module>
    from qutip.qobj import *
  File "/usr/local/lib/python2.7/site-packages/qutip/qobj.py", line 60, in <module>
    from qutip.ptrace import _ptrace
  File "/usr/local/lib/python2.7/site-packages/qutip/ptrace.py", line 38, in <module>
    from qutip.sparse import sp_reshape
  File "/usr/local/lib/python2.7/site-packages/qutip/sparse.py", line 49, in <module>
    from qutip.cy.sparse_utils import (_sparse_profile, _sparse_permute,
  File "/usr/local/lib/python2.7/site-packages/qutip/cy/__init__.py", line 1, in <module>
    from qutip.cy.spmatfuncs import *
  File "/usr/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 431, in load_module
    language_level=self.language_level)
  File "/usr/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 209, in load_module
    inplace=build_inplace, language_level=language_level)
  File "/usr/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 186, in build_module
    reload_support=pyxargs.reload_support)
  File "/usr/local/lib/python2.7/site-packages/pyximport/pyxbuild.py", line 100, in pyx_to_dll
    dist.run_commands()
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python2.7/site-packages/Cython/Distutils/build_ext.py", line 163, in run
    _build_ext.build_ext.run(self)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 337, in run
    self.build_extensions()
  File "/usr/local/lib/python2.7/site-packages/Cython/Distutils/build_ext.py", line 171, in build_extensions
    self.build_extension(ext)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 496, in build_extension
    depends=ext.depends)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/ccompiler.py", line 574, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/unixccompiler.py", line 122, in _compile
    raise CompileError, msg
ImportError: Building module qutip.cy.spmatfuncs failed: ["CompileError: command 'clang' failed with exit status 1\n"]
Your system is ready to brew.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
rharper2commented, Jan 18, 2016

I have just had the same problem, (I installed additional stuff with home-brew and it broke qutip).

As a complete hack workaround I noticed that DistUtil was passing to the qutip cython builder only (in my case) /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/include/python2.7 whereas numpy was returning np.get_include() -> /usr/local/lib/python2.7/site-packages/numpy/core/include

For some reason this is not being passed in properly by qutip’s setup.py.

Rather than dig any further I just did…

ln -s /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/include/python2.7/numpy

So I could get on with things.

0reactions
quantshahcommented, Nov 30, 2016

I am now trying to setup a developement environment using python setup.py develop and python setup.py build_ext --inplace but getting the error

cy/stochastic.pyx: cannot find cimported module 'qutip.cy.spmatfuncs'
Appending qutip.cy configuration to qutip
Ignoring attempt to set 'name' (from 'qutip' to 'qutip.cy')
Appending qutip.control configuration to qutip
Ignoring attempt to set 'name' (from 'qutip' to 'qutip.control')
Traceback (most recent call last):
  File "setup.py", line 18, in <module>
    setup(**configuration(top_path='').todict())
  File "setup.py", line 10, in configuration
    if os.environ['FORTRAN_LIBS'] == 'TRUE':
  File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserDict.py", line 40, in __getitem__
    raise KeyError(key)
KeyError: 'FORTRAN_LIBS'

I have gcc and gfortran installed and I suspect this might also be due to some issue with the file paths. I will try to get a workaround and post soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common Issues - Homebrew Documentation
You need to have the Xcode Command Line Utilities installed (and updated): run xcode-select --install in the terminal. Ruby: bad interpreter: /usr/bin/ruby^M: ...
Read more >
Homebrew installation failed - macos - Apple StackExchange
I removed the HomeBrew files by running the following command. After that, I ran the installation as mentioned in the above post.
Read more >
Homebrew installation error: "not a valid ref - Stack Overflow
I encountered this error on my brand new Macbook Pro with the M2 processor. What worked for me was removing the contents of...
Read more >
Fail to install on new Mac - bash script error #8 - GitHub
Try downloading https://raw.githubusercontent.com/Homebrew/install/master/install.sh via your browser, then /bin/bash -c /path/to/install.sh .
Read more >
usr/local/Cellar is not writable (Homebrew, macOS) - YouTube
If you get the following error when trying to install or upgrade packages on your Mac by using Homebrew : Error : /usr/local/Cellar...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found