agentmorris / MegaDetector

MegaDetector is an AI model that helps conservation folks spend less time doing boring things with camera trap images.
MIT License
116 stars 24 forks source link

No module named 'ipython_genutils' #87

Closed agentmorris closed 1 year ago

agentmorris commented 1 year ago

I'm working on a Linux machine. When preparing the "cameratraps-detector" environment from the environment-detector.yml file, I kept getting a series of errors regarding the ipython_genutils module:

ModuleNotFoundError: No module named 'ipython_genutils'

I could fix the error by manually adding "ipython_genutils" to the dependencies in the .yml file but I'm not sure if this is the correct way to do it.

Here's the full record of error messages:

| Traceback (most recent call last):
  File "/home/david/miniconda3/envs/cameratraps-detector/lib/python3.8/runpy.py", line 185, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/home/david/miniconda3/envs/cameratraps-detector/lib/python3.8/runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "/home/david/miniconda3/envs/cameratraps-detector/lib/python3.8/site-packages/nb_conda_kernels/__init__.py", line 2, in <module>
    from .manager import CondaKernelSpecManager
  File "/home/david/miniconda3/envs/cameratraps-detector/lib/python3.8/site-packages/nb_conda_kernels/manager.py", line 14, in <module>
    from jupyter_client.kernelspec import KernelSpecManager, KernelSpec, NoSuchKernel
  File "/home/david/.local/lib/python3.8/site-packages/jupyter_client/__init__.py", line 4, in <module>
    from .connect import *
  File "/home/david/.local/lib/python3.8/site-packages/jupyter_client/connect.py", line 25, in <module>
    from ipython_genutils.path import filefind
ModuleNotFoundError: No module named 'ipython_genutils'

done
ERROR conda.core.link:_execute(740): An error occurred while installing package 'conda-forge::nb_conda_kernels-2.3.1-py38h578d9bd_2'.
Rolling back transaction: done

LinkError: post-link script failed for package conda-forge::nb_conda_kernels-2.3.1-py38h578d9bd_2
location of failed script: /home/david/miniconda3/envs/cameratraps-detector/bin/.nb_conda_kernels-post-link.sh
==> script messages <==
Traceback (most recent call last):
  File "/home/david/miniconda3/envs/cameratraps-detector/lib/python3.8/runpy.py", line 185, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/home/david/miniconda3/envs/cameratraps-detector/lib/python3.8/runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "/home/david/miniconda3/envs/cameratraps-detector/lib/python3.8/site-packages/nb_conda_kernels/__init__.py", line 2, in <module>
    from .manager import CondaKernelSpecManager
  File "/home/david/miniconda3/envs/cameratraps-detector/lib/python3.8/site-packages/nb_conda_kernels/manager.py", line 14, in <module>
    from jupyter_client.kernelspec import KernelSpecManager, KernelSpec, NoSuchKernel
  File "/home/david/.local/lib/python3.8/site-packages/jupyter_client/__init__.py", line 4, in <module>
    from .connect import *
  File "/home/david/.local/lib/python3.8/site-packages/jupyter_client/connect.py", line 25, in <module>
    from ipython_genutils.path import filefind
ModuleNotFoundError: No module named 'ipython_genutils'

==> script output <==
stdout: 
stderr: 
return code: 1

()

Issue cloned from Microsoft/CameraTraps, original issue posted by DavidDHofmann on Feb 08, 2023.

agentmorris commented 1 year ago

I also had to specify "numpy=1.21"


(Comment originally posted by DavidDHofmann)

agentmorris commented 1 year ago

Hmmm, this is very odd. Since you found a solution that works for you, we appreciate you going the extra mile to find the root cause!

I haven't seen this before, and my search for similar issues in other repos isn't turning up anything that looks relevant. Because this issue is happening during the creation of the environment, it feels like it could be an issue with your conda installation, or a conflict with something that was installed in your base conda environment.

A couple questions:

  1. What Linux distribution and version are you using?

  2. Did you just install Anaconda for the first time to set up MegaDetector, or are you using Anaconda for other things?

  3. If you already had Anaconda installed, and you don't mind doing a bit more debugging, can you remove the newly-created environment (conda env remove -n cameratraps_detector), then update Anaconda (conda update conda), then try creating the cameratraps-detector environment again from the original environment-detector.yml file?

  4. If you already had Anaconda installed, but you're not using it for anything else, removing and re-installing Anaconda would be a helpful debugging step, though I don't want you to mess up other stuff on your machine just for this, so this may be the point where further debugging is no longer worth it.

Thanks for trying to track down the issue!


(Comment originally posted by agentmorris)

agentmorris commented 1 year ago

Hi Dan

I'm working with Linux Mint 20.3 (Una) with a custom kernel for surface devices (6.1.9-surface). On another computer with the same OS the conda setup works perfectly fine. I was using a miniconda installation, but even removing environments, upgrading, or reinstalling miniconda didn't solve the issue. Anyhow, by adding the ipython_genutils and numpy=1.21 dependencies I can get everything to work as expected.


(Comment originally posted by DavidDHofmann)

agentmorris commented 1 year ago

Glad you got it working. Since you have a fix, and this is a somewhat unusual environment, I'm not going to dig any deeper here. Will recommend manually installing ipython_genutils and numpy 2.1 if this comes up again. Thanks!


(Comment originally posted by agentmorris)