Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'caiman' #1019

Closed
ambtetl opened this issue Nov 16, 2022 · 23 comments
Closed

ModuleNotFoundError: No module named 'caiman' #1019

ambtetl opened this issue Nov 16, 2022 · 23 comments
Labels
type: issue with another package Issue is not with caiman

Comments

@ambtetl
Copy link

ambtetl commented Nov 16, 2022

For better support, please use the template below to submit your issue. When your issue gets resolved please remember to close it.

Sometimes errors while running CNMF occur during parallel processing which prevents the log to provide a meaningful error message. Please reproduce your error with setting dview=None.

If you need to upgrade CaImAn follow the instructions given in the documentation.

  • Tell us a bit about your setup:
  1. Operating system (Linux/macOS/Windows):
    Windows

  2. Python version (3.x):
    Python 3.10.6

  3. Working environment (Python IDE/Jupyter Notebook/other):
    Python IDE I believe

  4. Which of the demo scripts you're using for your analysis (if applicable):

  5. CaImAn version*:
    CaImAn1.8.8

  6. CaImAn installation process (pip install ./pip install -e ./conda):
    pip install -e I believe.

*You can get the CaImAn version by creating a params object and then typing params.data['caiman_version']. If the field doesn't exist, type N/A and consider upgrading)

  • Describe the issue that you are experiencing
    My apologies but I am very new to Python. So I am sure I am possibly missing something very obvious, but I have not been able to resolve this issue. I have already installed Caiman but when I go to run batch manager I receive the following error.

  • Copy error log below
    Traceback (most recent call last):
    File "C:\Users\tetloa01\Anaconda3\envs\mesmerize\lib\site-packages\mesmerize\viewer\modules\batch_run_modules\caiman_motion_correction.py", line 23, in

    import caiman as cm
    ModuleNotFoundError: No module named 'caiman'

  • If you're not reporting an error, type your message below

@pgunn
Copy link
Member

pgunn commented Nov 16, 2022

Hello,
After you install caiman, are you certain the way you're launching the batch manager leaves you in the correct conda environment? You might get this "no module named caiman" message if you were to launch from outside that environment.

If you can use the terminal to activate your caiman environment, then bring up a python interactive shell (by typing just "python" from the command prompt), and then do "import caiman", what happens?

@ambtetl
Copy link
Author

ambtetl commented Nov 16, 2022

Thank you so much for the fast response!

(base) PS C:> conda activate caiman
(caiman) PS C:> python
Python 3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:30:19) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import caiman
C:\Users\tetloa01\Anaconda3\envs\caiman\lib\site-packages\scipy_init_.py:146: UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.23.4
warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"

I have made sure that NumPy and SciPy are upgraded as well
(caiman) PS C:> pip install numpy --upgrade
Requirement already satisfied: numpy in c:\users\tetloa01\anaconda3\envs\caiman\lib\site-packages (1.23.4)
(caiman) PS C:> pip install sciPy --upgrade
Requirement already satisfied: sciPy in c:\users\tetloa01\anaconda3\envs\caiman\lib\site-packages (1.7.3)
Collecting sciPy
Using cached scipy-1.9.3-cp310-cp310-win_amd64.whl (40.1 MB)
Requirement already satisfied: numpy<1.26.0,>=1.18.5 in c:\users\tetloa01\anaconda3\envs\caiman\lib\site-packages (from sciPy) (1.23.4)
Installing collected packages: sciPy
Attempting uninstall: sciPy
Found existing installation: scipy 1.7.3
Uninstalling scipy-1.7.3:
Successfully uninstalled scipy-1.7.3
Successfully installed sciPy-1.9.3
(caiman) PS C:>

@pgunn
Copy link
Member

pgunn commented Nov 16, 2022

Hello,
I don't recommend using pip to replace any packages in your conda environment.

What we saw above was a warning; if that's all you got then caiman presumably imported successfully from that commandline and we just need to figure out why it wasn't loaded when you were trying to run the demo?

@ambtetl
Copy link
Author

ambtetl commented Nov 16, 2022

Where would I need to go to find any information to help figure out where the error is deriving from?

@pgunn
Copy link
Member

pgunn commented Nov 16, 2022

I suggest:
A) Remove and recreate the caiman environment with no pip replacement of packages.
B) From the commandline import caiman, and let me know if it imports successfully (don't worry about warnings, just errors)

@kushalkolar
Copy link
Collaborator

@ambtetl seems like you're using the mesmerize desktop app, this is the repo for that: https:/kushalkolar/MESmerize

Also BTW we don't recommend the desktop app anymore, it's been superseeded by mesmerize-core which has a lot of improvements: https:/nel-lab/mesmerize-core

Anyways, I'm guessing you probably haven't set the "pre-run" commands in the system config, you need to specify the environment there: http://docs.mesmerizelab.org/en/master/user_guides/general/misc.html#systemconfiguration

@ambtetl
Copy link
Author

ambtetl commented Nov 16, 2022

@pgunn Now when I run, I am not receiving any messages after import caiman

@ambtetl
Copy link
Author

ambtetl commented Nov 16, 2022

Would it then be easier to uninstall and install mesmerize-core?

@kushalkolar
Copy link
Collaborator

@ambtetl yes I'd recommend mesmerize-core over the old mesmerize desktop application, I notice you're using windows and there's currently an issue with running batches on some windows machines. You could try it out now or wait for a few days, I plan to have a fix and make a new release (which will also go on conda-forge) by the end of the week.

@ambtetl
Copy link
Author

ambtetl commented Nov 17, 2022

@kushalkolar I am trying to install before the end of the week to be able to work remotely, so if possible I would like to try to get this running asap. Again, my apologies for my questions as a very novice user. I greatly appreciate all of you help so far! I have attempted to install mesmerize-core using the install instructions under the conda section of https:/nel-lab/mesmerize-core. To launch "mesmerize-core" should be used instead of "mesmerize", correct? When I run (base) PS C:\CaImAn> caimanmanager.py install I do not get any messages or errors, and my windows terminal briefly opens and closes. Then whenever I try to run ipython to verify mesmerize_core is installed I get the following message

In [1]: import mesmerize_core^M
...: mesmerize_core.version

ImportError Traceback (most recent call last)
Cell In [1], line 1
----> 1 import mesmerize_core
2 mesmerize_core.version

File ~\Anaconda3\envs\mesmerize-core\lib\site-packages\mesmerize_core_init_.py:1
----> 1 from .batch_utils import (
2 set_parent_raw_data_path,
3 get_parent_raw_data_path,
4 load_batch,
5 create_batch,
6 )
7 from .caiman_extensions import *
8 from pathlib import Path

File ~\Anaconda3\envs\mesmerize-core\lib\site-packages\mesmerize_core\batch_utils.py:7
3 from typing import Union
5 import pandas as pd
----> 7 from .algorithms import cnmf, mcorr
8 from .algorithms import cnmfe
9 from .utils import validate_path

File ~\Anaconda3\envs\mesmerize-core\lib\site-packages\mesmerize_core\algorithms\cnmf.py:3
1 """Performs CNMF in a separate process"""
2 import click
----> 3 import caiman as cm
4 from caiman.source_extraction.cnmf import cnmf as cnmf
5 from caiman.source_extraction.cnmf.params import CNMFParams

File C:\CaImAn\caiman_init_.py:4
1 #!/usr/bin/env python
3 import pkg_resources
----> 4 from .base.movies import movie, load, load_movie_chain, _load_behavior
5 from .base.timeseries import concatenate
6 from .cluster import start_server, stop_server

File C:\CaImAn\caiman\base\movies.py:59
56 from .traces import trace
58 from ..mmapping import load_memmap
---> 59 from ..utils import visualization
60 from .. import summary_images as si
61 from ..motion_correction import apply_shift_online, motion_correct_online

File C:\CaImAn\caiman\utils\visualization.py:37
34 import functools as fct
36 from ..base.rois import com
---> 37 from ..summary_images import local_correlations
39 try:
40 cv2.setNumThreads(0)

File C:\CaImAn\caiman\summary_images.py:23
20 from typing import Any, List, Optional, Tuple
22 import caiman as cm
---> 23 from caiman.source_extraction.cnmf.pre_processing import get_noise_fft
24 from caiman.source_extraction.cnmf.utilities import get_file_size
26 def max_correlation_image(Y, bin_size: int = 1000, eight_neighbours: bool = True, swap_dim: bool = True) -> np.ndarray:

File C:\CaImAn\caiman\source_extraction\cnmf_init_.py:12
10 from . import spatial
11 from . import temporal
---> 12 from . import oasis
13 from . import params
14 from . import online_cnmf

ImportError: cannot import name 'oasis' from partially initialized module 'caiman.source_extraction.cnmf' (most likely due to a circular import) (C:\CaImAn\caiman\source_extraction\cnmf_init_.py)

In [2]:

@kushalkolar
Copy link
Collaborator

kushalkolar commented Nov 17, 2022 via email

@ambtetl
Copy link
Author

ambtetl commented Nov 17, 2022 via email

@kushalkolar
Copy link
Collaborator

It seems like it's referring to a caiman dir outside your anaconda path. Did you manually set your PYTHONPATH env variable?

@pgunn
Copy link
Member

pgunn commented Nov 17, 2022

Another possibility is trying to import caiman from inside a source checkout, which people should avoid.

@ambtetl
Copy link
Author

ambtetl commented Nov 17, 2022

@kushalkolar
path screenshot.docx

This is what is currently in the system properties, without me manually setting the PYTHONPATH env variable. If I have to modify is should the value be the location for the env folder?

@kushalkolar
Copy link
Collaborator

Did you also try to move outside the caiman source dir as Pat suggested?

@ambtetl
Copy link
Author

ambtetl commented Nov 17, 2022 via email

@kushalkolar
Copy link
Collaborator

kushalkolar commented Nov 17, 2022 via email

@ambtetl
Copy link
Author

ambtetl commented Nov 17, 2022 via email

@kushalkolar
Copy link
Collaborator

I mean how are you launching the jupyter notebook after installation

@ambtetl
Copy link
Author

ambtetl commented Nov 17, 2022 via email

@kushalkolar
Copy link
Collaborator

kushalkolar commented Nov 17, 2022 via email

@EricThomson EricThomson added the type: issue with another package Issue is not with caiman label May 1, 2023
@EricThomson
Copy link
Contributor

Closing issue due to lack of activity. @ambtetl please let me know if this was a mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: issue with another package Issue is not with caiman
Projects
None yet
Development

No branches or pull requests

4 participants