[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ImportError: No module named multiarray (is back)

On 11/22/2011 04:38 PM, Mathieu Malaterre wrote:
[CC me please]

Hi all,

   The issue with multiarray came back. I manage to get things working
for the tifffile package installing the tifffile.py into
/usr/bin/tiffile (removing the py extension). However another package
is now failing: CellProfiler. Symptoms are:

$ python /usr/lib/python2.7/dist-packages/CellProfiler.py
Traceback (most recent call last):
   File "/usr/lib/python2.7/dist-packages/CellProfiler.py", line 17, in<module>
     import numpy as np
   File "/usr/share/pyshared/numpy/__init__.py", line 136, in<module>
     import add_newdocs
   File "/usr/share/pyshared/numpy/add_newdocs.py", line 9, in<module>
     from numpy.lib import add_newdoc
   File "/usr/share/pyshared/numpy/lib/__init__.py", line 4, in<module>
     from type_check import *
   File "/usr/share/pyshared/numpy/lib/type_check.py", line 8, in<module>
     import numpy.core.numeric as _nx
   File "/usr/share/pyshared/numpy/core/__init__.py", line 5, in<module>
     import multiarray
ImportError: No module named multiarray

Hi Mathieu,

I don't think that your problem can be solved in any simple way, apart from physically moving the script or providing a second helper script.

This is a very unfortunate interaction between Python semantics (prepend realpath of script to sys.path) and the Debian way of installing modules (symlink farm between Python versions). Nevertheless, I think that Python is wrong, and Debian is right. What Python does means that it is not possible to run a Python script from /tmp or any other directory writeable by other users securely. Even if this is by design, it is not advertised well (or maybe even at all?) and is thus a big security hole.

Now if I do:

$ cp /usr/lib/python2.7/dist-packages/CellProfiler.py /tmp
$ python /tmp/CellProfiler.py
Traceback (most recent call last):
   File "/tmp/CellProfiler.py", line 193, in<module>
     os.chdir(os.path.join(root, script_path))
OSError: [Errno 2] No such file or directory: '/tmp/cellprofiler/cpmath'

Could someone please point me to some documentation get rid definitely
of this kind of issues.
You can wait for Python 3.2 and the PEP 3149 (ABI version tagged .so files) which makes the Debian-style symlinks farms unnecessary (just joking :).


> I'd like to keep as much as the original
package as possible, therefore I would like to keep the
/usr/lib/python2.7/dist-packages/CellProfiler.py (or pyshared
equivalent). But how do I load this file ?

Thanks very much.

Reply to: