spack: Spack-built Python: ImportError: No module named _io

Has anyone seen this error message before?

$ /Users/Adam/spack/opt/spack/darwin-sierra-x86_64/clang-8.0.0-apple/python-2.7.13-tjqn5npfo573q2jw3dumzhzctfd2vvdv/bin/python
Python 2.7.10 (default, Jul 30 2016, 19:40:32) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/Adam/spack/opt/spack/darwin-sierra-x86_64/clang-8.0.0-apple/python-2.7.13-tjqn5npfo573q2jw3dumzhzctfd2vvdv/lib/python2.7/io.py", line 51, in <module>
    import _io
ImportError: No module named _io

It occurs for me on develop, but only on macOS. It’s definitely new, as I’ve never seen it before. @davydden?

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

According to the Python developers:

My guess is that you will find that the problem goes away if you avoid the use of --enable-shared on the Python configure; most Python distributions on macOS use --enable-framework rather than --enable-shared and we seldom test it. Or use neither.

Removing --enable-shared from the build solves the problem. I think this is the best way to go, at least on macOS. Unfortunately, adding --enable-framework causes make install to fail and I don’t know why.

@adamjstewart: For what it’s worth, this was the error I was getting before #1435 was merged. The problem was that user configuration was getting in the way and causing shared libraries (e.g. _io.so) from being installed in the Python Spack directory. It may be worthwhile to check and see if _io.so is located in /path/to/spack/python/lib/python2.7/lib-dynload and to figure out what could be redirecting it if it isn’t present.