Module not found error but package is installed?

Hi everyone, I am new to conda and package managing in general. I work on WSL 2 Ubuntu. Please help me solve this problem, I am not sure what is going on.

Env file:

name: test_env
channels:
  - fastai
  - conda_forge
  - defaults
dependencies:
  - fastai=1.0.61
  - python=3.8.6

After creating and activating the environment I ran:

python
import fastai

Output:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'fastai'

I have tested just listing fastai without specifying any version (I’m assuming it just installs the latest version?) and it did work, however I would like to use this particular version if possible to follow a 2021 repo.

I have reinstalled conda and recreating the environment but no luck.

Any help would be appreciated!

Can you try with just channels: [fastai, conda-forge]? Notice the dash instead of the underscore.

I can’t reproduce with:

conda create -n fastai --override-channels -c fastai -c conda-forge fastai=1.0.61 python=3.8.6
conda activate fastai
python -c "import fastai"

Thanks for your response!

My bad - I made that typo while editing the post. I did indeed use conda-forge.

I have investigated some more and it turned out that fastai was installed into /~/user/anaconda3/envs/test_env/site-packages, which for some reason was not in the search path… I manually added it and it solved the problem.

That’s not recommended. I think I know what happened.

You are using an older conda-libmamba-solver with libmamba 1.x. This version has a limitation where noarch: python packages like fastai are not properly detected UNLESS they depend on python itself. This is not the case for the fastai version you linked.

I could not reproduce because I’m using libmamba 2.x, which does not suffer from this limitation. You can update your base environment with conda update -n base conda conda-libmamba-solver libmambapy libmamba.

Ah, that explains it. Surprised it’s not included by default. Thanks.