condacolab icon indicating copy to clipboard operation
condacolab copied to clipboard

ModuleNotFoundError when installing via install_from_url()

Open gbayarri opened this issue 9 months ago • 0 comments

Hi, I'm installing a condacolab via install_from_url() because I need a conda/mamba with python 3.9 while colab is pinned to 3.10. I tried with several versions of mambaforge, included some of the official website or this:

https://github.com/jaimergp/miniforge/releases/tag/22.11.1-4_colab

I've tried as well with the conda constructor following the instruction of the condacolab pypi but modifying the version to 3.9:

name: condacolab  # you can edit this if you want
version: 0.1      # increment if you change the specs, for reproducibility!

channels:
  - conda-forge
specs:
  - python =3.9  # Python MUST be version 3.7
  - pip
  - conda
  - mamba  # mamba is not needed but recommended

# Pip dependencies are NOT recommended. If you do need them
# uncomment the line below and edit `pip-dependencies.sh`.
# post_install: pip-dependencies.sh

# do not edit below this line
# ---------------------------
installer_type: sh

After running all these installations, I load my environment.yml and the conda list shows the correct version of my dependencies. For example:

!conda list | grep ngl
nglview                   3.0.8              pyh1da8cd4_0    conda-forge

But when doing the import in a cell:

import nglview
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
[<ipython-input-12-dd30d89a3198>](https://localhost:8080/#) in <cell line: 1>()
----> 1 import nglview

ModuleNotFoundError: No module named 'nglview'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

The weirdest thing is that when I import this dependency in pure python it works:

!python
Python 3.9.19 | packaged by conda-forge | (main, Mar 20 2024, 12:50:21) 
[GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nglview
>>> nglview.demo()
NGLWidget()

Any idea of what I'm missing?

gbayarri avatar May 10 '24 10:05 gbayarri