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

Windows Installation: OpenCV Configuration File Missing #1460

Closed
FlynnOConnell opened this issue Feb 6, 2025 · 6 comments
Closed

Windows Installation: OpenCV Configuration File Missing #1460

FlynnOConnell opened this issue Feb 6, 2025 · 6 comments

Comments

@FlynnOConnell
Copy link

FlynnOConnell commented Feb 6, 2025

Following the new(ish) caiman install steps for Windows on miniforge3:

conda create -n caiman python=3.11 pip vs2019_win-64 && conda activate caiman
conda activate caiman
git clone <caiman url> 
cd caiman
pip install .

Importing caiman results in an error with opencv:

In [2]: import caiman as cm
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[2], line 1
----> 1 import caiman as cm

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

File ~\repos\CaImAn\caiman\base\movies.py:9
      1 #!/usr/bin/env python
      3 """ Suite of functions that help manage movie data
      4
      5 Contains the movie class.
      6
      7 """
----> 9 import cv2
     10 from functools import partial
     11 import h5py

File ~\miniforge3\envs\caiman\Lib\site-packages\cv2\__init__.py:181
    176             if DEBUG: print("Extra Python code for", submodule, "is loaded")
    178     if DEBUG: print('OpenCV loader: DONE')
--> 181 bootstrap()

File ~\miniforge3\envs\caiman\Lib\site-packages\cv2\__init__.py:112, in bootstrap()
    109         raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))
    111 load_first_config(['config.py'], True)
--> 112 load_first_config([
    113     'config-{}.{}.py'.format(sys.version_info[0], sys.version_info[1]),
    114     'config-{}.py'.format(sys.version_info[0])
    115 ], True)
    117 if DEBUG: print('OpenCV loader: PYTHON_EXTENSIONS_PATHS={}'.format(str(l_vars['PYTHON_EXTENSIONS_PATHS'])))
    118 if DEBUG: print('OpenCV loader: BINARIES_PATHS={}'.format(str(l_vars['BINARIES_PATHS'])))

File ~\miniforge3\envs\caiman\Lib\site-packages\cv2\__init__.py:109, in bootstrap.<locals>.load_first_config(fnames, required)
    107     return True
    108 if required:
--> 109     raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))

ImportError: OpenCV loader: missing configuration file: ['config-3.11.py', 'config-3.py']. Check OpenCV installation.

I've tried installing opencv with conda install conda-forge::opencv, then I get partially initialized module:

Traceback (most recent call last)
Cell In[1], line 1
----> 1 import caiman as cm

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

File ~\repos\CaImAn\caiman\base\movies.py:36
     34 import caiman.base.traces
     35 import caiman.mmapping
---> 36 import caiman.summary_images
     37 import caiman.utils.sbx_utils
     38 import caiman.utils.visualization

File ~\repos\CaImAn\caiman\summary_images.py:18
     16 import caiman
     17 import caiman.base.movies
---> 18 from caiman.source_extraction.cnmf.pre_processing import get_noise_fft
     20 def max_correlation_image(Y, bin_size: int = 1000, eight_neighbours: bool = True, swap_dim: bool = True) -> np.ndarray:
     21     """Computes the max-correlation image for the input dataset Y with bin_size
     22
     23     Args:
   (...)
     40             max correlation image
     41     """

File ~\repos\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:\Users\RBO\repos\CaImAn\caiman\source_extraction\cnmf\__init__.py)

conda setup:

$ conda info

     active environment : caiman
    active env location : C:\Users\RBO\miniforge3\envs\caiman
            shell level : 8
       user config file : C:\Users\RBO\.condarc
 populated config files : C:\Users\RBO\miniforge3\.condarc
                          C:\Users\RBO\.condarc
          conda version : 24.11.3
    conda-build version : not installed
         python version : 3.12.6.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=skylake
                          __conda=24.11.3=0
                          __cuda=12.6=0
                          __win=0=0
       base environment : C:\Users\RBO\miniforge3  (writable)
      conda av data dir : C:\Users\RBO\miniforge3\etc\conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
                          https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : C:\Users\RBO\miniforge3\pkgs
                          C:\Users\RBO\.conda\pkgs
                          C:\Users\RBO\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\RBO\miniforge3\envs
                          C:\Users\RBO\.conda\envs
                          C:\Users\RBO\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/24.11.3 requests/2.32.3 CPython/3.12.6 Windows/10 Windows/10.0.19045 solver/libmamba conda-libmamba-solver/24.7.0 libmambapy/1.5.10
          administrator : True
             netrc file : None
           offline mode : False
@pgunn
Copy link
Member

pgunn commented Feb 6, 2025

I think that "partially initialized module" thing is very close to working; the only thing you need to change is to leave the source directory (run caimanmanager install and then enter the caiman_data directory under your homedir; THEN start your scripts or jupyter and it will probably work).

Give this a go; if that doesn't work we can look more deeply. The compile route on Windows has been messy for a long time, but we should be able to get you through it (maybe even with a videochat).

@FlynnOConnell
Copy link
Author

Giving this a go now. I'm right downstairs at the workshop so I could pop in and say hi.

@pgunn
Copy link
Member

pgunn commented Feb 6, 2025

We're probably on the same floor if you're on the 3rd floor. I'm in room 304 and will be free until about 2:30; come over if you have a sec.

@FlynnOConnell
Copy link
Author

caimanmanager install fixed this issue, but I did need to add opencv to the conda install (or install it manually after creating the env as shown in the readme).

I won't have time to make it by 230, can you let me know if you have any time in the afternoon?

@pgunn
Copy link
Member

pgunn commented Feb 6, 2025

I may be free sometime around 4:30, maybe sooner. I'm meeting with someone else at 4pm, but that may be a fairly brief meeting - not sure.

Drop me an email at [email protected] and I'll ping you when I'm free.

@FlynnOConnell
Copy link
Author

Resolved, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants