ecaruyer / phantomas

Create realistic digital phantoms in diffusion MRI.
Other
31 stars 16 forks source link

ImportError: No module named fast_volume_fraction #28

Open sbaete opened 10 years ago

sbaete commented 10 years ago

After downloading and installing phantomas, I get the following when I run "phantomas_dwis -h"

Traceback (most recent call last): File "/usr/local/bin/phantomas_dwis", line 19, in from phantomas.mr_simul.fod \ File "/media/hda6/Experimenten/phantomas/phantomas/mr_simul/fod.py", line 7, in from .fast_volume_fraction import * ImportError: No module named fast_volume_fraction

I've tried several things and searched a bit and it seems that the cython-module fast_volume_fraction doesn't get imported correctly. However it did compile: steven@SterlingArcher /media/hda6/Experimenten/phantomas/build/lib.linux-x86_64-2.7/phantomas/mr_simul $ ls fast_volume_fraction fast_volume_fraction.so fod.py image_formation.py init.py partial_volume.py spherical_21_design.txt synthetic.py steven@SterlingArcher /media/hda6/Experimenten/phantomas/build/lib.linux-x86_64-2.7/phantomas/mr_simul $ ls fast_volume_fraction init.py pyx.so steven@SterlingArcher /media/hda6/Experimenten/phantomas/build/lib.linux-x86_64-2.7/phantomas/mr_simul $

Python is novel to me, so I'm not sure how to solve it. Do you have a solution for this?

ecaruyer commented 10 years ago

Hi sbaete,

Could you tell me which OS you are running, and how you setup phantomas (which command line did you use?). Any error message or warning during setup?

sbaete commented 10 years ago

Dear ecaruyer,

Thank you for your help.

I'm running LinuxMint 15, which is built on ubuntu 13.04.

The setup was as follows:

steven@SterlingArcher /Exp/phantomas $ sudo python setup.py install [sudo] password for steven: running install running build running build_py copying phantomas/mr_simul/fod.py -> build/lib.linux-x86_64-2.7/phantomas/mr_simul running build_ext running build_scripts running install_lib copying build/lib.linux-x86_64-2.7/phantomas/mr_simul/fod.py -> /usr/local/lib/python2.7/dist-packages/phantomas/mr_simul byte-compiling /usr/local/lib/python2.7/dist-packages/phantomas/mr_simul/fod.py to fod.pyc running install_scripts changing mode of /usr/local/bin/phantomas_masks to 755 changing mode of /usr/local/bin/phantomas_rois to 755 changing mode of /usr/local/bin/phantomas_view to 755 changing mode of /usr/local/bin/phantomas_struct to 755 changing mode of /usr/local/bin/phantomas_dwis to 755 running install_egg_info Removing /usr/local/lib/python2.7/dist-packages/Phantomas-0.1.dev.egg-info Writing /usr/local/lib/python2.7/dist-packages/Phantomas-0.1.dev.egg-info steven@SterlingArcher /Exp/phantomas $

ecaruyer commented 10 years ago

Just a guess, it is very likely that your $PWD (working directory) was /media/hda6/Experimenten/phantomas when you launched the command phantomas_dwis. In which case, Python imported /media/hda6/Experimenten/phantomas/phantomas/mr_simul/fod.py rather than the setup version of fod.py, and could not find any module named fast_volume_fraction

Could you change your working directory to e.g. ~/ and try again?

sbaete commented 10 years ago

Good idea! Unfortunately, this doesn't seem to be the problem:

steven@SterlingArcher ~ $ echo $PYTHONPATH /usr/bin/python:/media/hda6/Experimenten/dipy steven@SterlingArcher ~ $ phantomas_dwis -h Traceback (most recent call last): File "/usr/local/bin/phantomas_dwis", line 19, in from phantomas.mr_simul.fod \ File "/usr/local/lib/python2.7/dist-packages/phantomas/mr_simul/fod.py", line 7, in from .fast_volume_fraction import * AttributeError: 'module' object has no attribute 'fast_volume_fraction'

ecaruyer commented 10 years ago

Well this is a tricky one... could you also report the contents of /usr/local/lib/python2.7/dist-packages/phantomas/mr_simul/ directory?

sbaete commented 10 years ago

Indeed ;)

It looks like all the files are where they need to be:

steven@SterlingArcher /usr/local/lib/python2.7/dist-packages/phantomas $ tree . ├── geometry │   ├── fiber.py │   ├── fiber.pyc │   ├── init.py │   ├── init.pyc │   ├── models.py │   ├── models.pyc │   ├── rois.py │   ├── rois.pyc │   ├── utils.py │   └── utils.pyc ├── init.py ├── init.pyc ├── mr_simul │   ├── fast_volume_fraction │   │   ├── init.py │   │   ├── init.pyc │   │   └── pyx.so │   ├── fast_volume_fraction.so │   ├── fod.py │   ├── fod.pyc │   ├── image_formation.py │   ├── image_formation.pyc │   ├── init.py │   ├── init.pyc │   ├── partial_volume.py │   ├── partial_volume.pyc │   ├── spherical_21_design.txt │   ├── synthetic.py │   └── synthetic.pyc ├── utils │   ├── init.py │   ├── init.pyc │   ├── shm.py │   ├── shm.pyc │   ├── tessellation.py │   └── tessellation.pyc └── visu ├── init.py ├── init.pyc ├── views.py └── views.pyc

5 directories, 37 files

ecaruyer commented 10 years ago

Thanks for the detailed report, Not sure where the directory mr_simul/fast_volume_fraction comes from. I don't have this in my local install... Any idea @gabknight @samuelstjean @jchoude?

samuelstjean commented 10 years ago

No idea, but that fast_volume_fraction fraction is not present on my system either, although I use a local copy, I didn't run the setup.py for system-wide installation. Maybe something got screwed because of that?

Can you try build locally with python setup.py build_ext inside the root phantomas folder, and adding that to your python path? Also check is the folder is present in that version, could be the problem, who knows.

sbaete commented 10 years ago

Thank you for your help,

I ran the setup.py build_ext: steven@SterlingArcher /Exp/phantomas $ sudo python setup.py build_ext running build_ext skipping 'phantomas/mr_simul/fast_volume_fraction.c' Cython extension (up-to-date)

Now, the tree looks like this: steven@SterlingArcher /Exp/phantomas/phantomas $ tree . ├── geometry │   ├── fiber.py │   ├── fiber.pyc │   ├── init.py │   ├── init.pyc │   ├── models.py │   ├── models.pyc │   ├── rois.py │   ├── rois.pyc │   ├── tests │   │   └── init.py │   ├── utils.py │   └── utils.pyc ├── init.py ├── init.pyc ├── mr_simul │   ├── c_fast_volume_fraction.c │   ├── fast_volume_fraction.c │   ├── fast_volume_fraction.c.bac │   ├── fast_volume_fraction.pyx │   ├── fod.py │   ├── fod.pyc │   ├── image_formation.py │   ├── image_formation.pyc │   ├── init.py │   ├── init.pyc │   ├── partial_volume.py │   ├── partial_volume.pyc │   ├── spherical_21_design.txt │   ├── synthetic.py │   └── tests │   ├── init.py │   └── test_fast_volume_fraction.py ├── utils │   ├── init.py │   ├── shm.py │   └── tessellation.py └── visu ├── init.py ├── init.pyc ├── views.py └── views.pyc

6 directories, 36 files

And indeed, the folder mr_simu/fast_volume_fraction doesn't show up.

I changed the python path (see below), however, I get the same result:

steven@SterlingArcher /Exp/phantomas/phantomas $ echo $PYTHONPATH /media/hda6/Experimenten/dipy::/media/hda6/Experimenten/phantomas/phantomas steven@SterlingArcher /Exp/phantomas/phantomas $ phantomas_dwis -h Traceback (most recent call last): File "/usr/local/bin/phantomas_dwis", line 19, in from phantomas.mr_simul.fod \ File "/usr/local/lib/python2.7/dist-packages/phantomas/mr_simul/fod.py", line 7, in from .fast_volume_fraction import * AttributeError: 'module' object has no attribute 'fast_volume_fraction'

samuelstjean commented 10 years ago

This is because you stil have it installed systemwide, and it's using that version instead of the one you just compiled.

One way to fix it would be to removed the phantomas version installed in /usr/local/lib/python2.7/dist-packages/phantomas (just delete the folder and everything else inside) and run python setup.py build_ext (no need for sudo).

This will compile it locally as your user, so you can then add this folder to the pythonpath. For example, mine contains /home/local/USHERBROOKE/stjs2902/git/phantomas, which is my local fork root folder.

sbaete commented 10 years ago

Thanks,

I removed the version in /usr/local/lib/python2.7/dist-packages steven@SterlingArcher /usr/local/lib/python2.7/dist-packages $ ls phant ls: cannot access phant: No such file or directory

and I removed the scripts from /usr/local/bin

steven@SterlingArcher /usr/local/bin $ ls phant ls: cannot access phant: No such file or directory However, the problem remains the same. It's a stubborn problem apparently ... This is the output:

steven@SterlingArcher /Exp/phantomas $ echo $PYTHONPATH /media/hda6/Experimenten/dipy:/media/hda6/Experimenten/phantomas steven@SterlingArcher /Exp/phantomas $ ./scripts/phantomas_dwis -h Traceback (most recent call last): File "./scripts/phantomas_dwis", line 19, in from phantomas.mr_simul.fod \ File "/media/hda6/Experimenten/phantomas/phantomas/mr_simul/fod.py", line 7, in from .fast_volume_fraction import * ImportError: No module named fast_volume_fraction

samuelstjean commented 10 years ago

Did you compile the module locally? Other thing is that you seem to use it from an external hard drive, but I don't know if that can cause problem. My last advice would be to try a locally compiled version on your computer, and if that doesn't work I must admit I'm also out of idea after this.

sbaete commented 10 years ago

I understand your concern, so I went ahead and started from scratch in my home directory. Everything looks fine to me, the other scripts also seem to work, it's only the phantomas_dwis-script which gives an error.

steven@SterlingArcher ~ $ git clone https://github.com/ecaruyer/phantomas.git Cloning into 'phantomas'... remote: Counting objects: 459, done. remote: Total 459 (delta 0), reused 0 (delta 0) Receiving objects: 100% (459/459), 130.28 KiB | 0 bytes/s, done. Resolving deltas: 100% (284/284), done. Checking connectivity... done. steven@SterlingArcher ~ $ cd phantomas/ steven@SterlingArcher ~/phantomas $ python setup.py build_ext running build_ext cythoning phantomas/mr_simul/fast_volume_fraction.pyx to phantomas/mr_simul/fast_volume_fraction.c building 'phantomas.mr_simul.fast_volume_fraction' extension creating build creating build/temp.linux-x86_64-2.7 creating build/temp.linux-x86_64-2.7/phantomas creating build/temp.linux-x86_64-2.7/phantomas/mr_simul x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/include/ -I/usr/include/python2.7 -c phantomas/mr_simul/fast_volume_fraction.c -o build/temp.linux-x86_64-2.7/phantomas/mr_simul/fast_volume_fraction.o In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1728:0, from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:17, from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:15, from phantomas/mr_simul/fast_volume_fraction.c:256: /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_deprecated_api.h:11:2: warning: #warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp] In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:26:0, from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:15, from phantomas/mr_simul/fast_volume_fraction.c:256: /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/multiarray_api.h:1594:1: warning: ‘_import_array’ defined but not used [-Wunused-function] In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ufuncobject.h:311:0, from phantomas/mr_simul/fast_volume_fraction.c:257: /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ufunc_api.h:236:1: warning: ‘_import_umath’ defined but not used [-Wunused-function] x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/include/ -I/usr/include/python2.7 -c phantomas/mr_simul/c_fast_volume_fraction.c -o build/temp.linux-x86_64-2.7/phantomas/mr_simul/c_fast_volume_fraction.o creating build/lib.linux-x86_64-2.7 creating build/lib.linux-x86_64-2.7/phantomas creating build/lib.linux-x86_64-2.7/phantomas/mr_simul x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/phantomas/mr_simul/fast_volume_fraction.o build/temp.linux-x86_64-2.7/phantomas/mr_simul/c_fast_volume_fraction.o -L/usr/lib/ -lgsl -lgslcblas -o build/lib.linux-x86_64-2.7/phantomas/mr_simul/fast_volume_fraction.so steven@SterlingArcher ~/phantomas $ PYTHONPATH=$PYTHONPATH:~/phantomas steven@SterlingArcher ~/phantomas $ echo $PYTHONPATH /media/hda6/Experimenten/dipy::/home/steven/phantomas steven@SterlingArcher ~/phantomas $ ./scripts/phantomas_dwis -h Traceback (most recent call last): File "./scripts/phantomas_dwis", line 19, in from phantomas.mr_simul.fod \ File "/home/steven/phantomas/phantomas/mr_simul/fod.py", line 7, in from .fast_volume_fraction import * ImportError: No module named fast_volume_fraction steven@SterlingArcher ~/phantomas $ ./scripts/phantomas_rois -h usage: phantomas_rois [-h] [--res RES] [--fov FOV] geometry

Prepare regions of interest for connectivity analysis.

positional arguments: geometry A JSON-formatted file describing fiber and phantom geometries.

optional arguments: -h, --help show this help message and exit --res RES Diffusion-weighted images resolution in mm. --fov FOV Field of view in mm. If None, adapts to the size of the phantom.

samuelstjean commented 10 years ago

Well, that is indeed weird, can you give us your version of the dependencies, namely cython, numpy, scipy and scikit sparse? Maybe cython does compile it, but the stock version from mint 15 could be old and produce a non-working file maybe. For example, dipy requires a newer version than the one in the default repo to be able to run properly.

sbaete commented 10 years ago

Another great idea! The versions I was using are: Cython version 0.17.4, numpy version 1.7.1, scipy version 0.11.0 and scikits.sparse 0.2. Following your suggestion, I updated cython to 0.20.2, re-cloned from git and started from scratch, though everything remains the same.

steven@SterlingArcher ~/phantomas $ ./scripts/phantomas_dwis -hTraceback (most recent call last): File "./scripts/phantomas_dwis", line 19, in from phantomas.mr_simul.fod \ File "/home/steven/phantomas/phantomas/mr_simul/fod.py", line 7, in from .fast_volume_fraction import * ImportError: No module named fast_volume_fraction

samuelstjean commented 10 years ago

Now I'm really out of idea, I'm on numpy 1.7.2, scipy 0.14-dev, cython 0.19.2 and scikits-sparse 0.2, so unless something broke in a more recent version of cython (probably not) I can't say sadly.

sbaete commented 10 years ago

After some more searching and trying around, I eventually made a new virtual ubuntu 14.04.1 machine and installed phantomas and all the necessary packages. On that virtual machine everything works perfect. For the moment that solves my problem, but if you guys would have any more ideas on how to get it running on my system, let me know. I'm guessing it's an unfortunate combination of libraries.

Thank you for your help yesterday and looking forward to start using the package!

Best regards,

Steven

ecaruyer commented 10 years ago

Thanks for the feedback, Steven and thanks @samuelstjean for your help! Sorry for not being more helpful... I'll try to setup Mint 15 in a virtual box next week to reproduce your issue.

Cheers, Manu.

samuelstjean commented 10 years ago

According to internet, ubuntu 13.04 has benn EOL since january, so if it's the same for mint 15, it would kinda be a waste of time to debug it, unless said problem also happens on recent versions as well.

sbaete commented 10 years ago

Indeed, if there are no other appearances of this issue, it might be a waste of time to further debug it. I only figured yesterday that ubuntu 13.04 is already EOL.

ecaruyer commented 10 years ago

Good catch, I did not realize that this was not an LTS. Well hope your workaround works for you. Keep us posted if you find anything!

2014-08-06 13:34 GMT-04:00 sbaete notifications@github.com:

Indeed, if there are no other appearances of this issue, it might be a waste of time to further debug it. I only figured yesterday that ubuntu 13.04 is already EOL.

— Reply to this email directly or view it on GitHub https://github.com/ecaruyer/phantomas/issues/28#issuecomment-51368851.

Postdoctoral research fellow Section of Biomedical Image Analysis University of Pennsylvania http://www.emmanuelcaruyer.com

oesteban commented 9 years ago

Same problem here, suddenly after having phantomas working for long.

Platform is Debian Jessie. Cython with both 0.14 and then updated to 0.22.1.

oesteban commented 9 years ago

I've submitted a patch that works for me. I had to manually remove everything installed system-wide. Specially, it looked important to remove the /usr/local/lib/python2.7/dist-packages/Phantomas-0.1.dev.egg-info file.