tbepler / topaz

Pipeline for particle picking in cryo-electron microscopy images using convolutional neural networks trained from positive and unlabeled examples. Also featuring micrograph and tomogram denoising with DNNs.
GNU General Public License v3.0
172 stars 64 forks source link

ImportError using topaz with python2.7 #69

Closed sbliven closed 3 years ago

sbliven commented 3 years ago

I've installed topaz with python2.7 (for use with cryosparc, so I don't think I can use 3?). I'm getting an error:

$ topaz --version
Traceback (most recent call last):
  File "/opt/psi/Programming/anaconda/2019.07/conda/envs/topaz-0.2.5/bin/topaz", line 11, in <module>
    load_entry_point('topaz-em==0.2.4', 'console_scripts', 'topaz')()
  File "/opt/psi/Programming/anaconda/2019.07/conda/envs/topaz-0.2.5/lib/python2.7/site-packages/topaz/main.py", line 68, in main
    import topaz.commands.denoise
  File "/opt/psi/Programming/anaconda/2019.07/conda/envs/topaz-0.2.5/lib/python2.7/site-packages/topaz/commands/denoise.py", line 77, in <module>
    import topaz.denoise as dn
  File "/opt/psi/Programming/anaconda/2019.07/conda/envs/topaz-0.2.5/lib/python2.7/site-packages/topaz/denoise.py", line 7, in <module>
    import torch.nn as nn
ImportError: No module named nn

Digging into this it looks like topaz.torch is shadowing pytorch's torch. Maybe torch.py should be renamed?

sbliven commented 3 years ago

This seems to be a python2/3 difference. Python 3 prefers the global package since the local one should be referenced .torch, while python2 loads the package-local file first.

tbepler commented 3 years ago

Thanks for pointing this out, I'll add this to the todo list. That said, I probably won't continue to support python 2 for much longer. I recommend using python 3 instead.

sbliven commented 3 years ago

Dropping python 2 seems very reasonable. I had originally installed following the cryosparc guide, which specifically fixes python=2.7. I later realized that there is no need to match python versions between topaz and cryosparc, so I've switched to python 3.

That said, it might still be a good idea to avoid namespace collisions with dependencies.

tbepler commented 3 years ago

This should now be resolved by commit 12f7a8a7ecc35a38c7f38fe799d549c0c82975d0