pythoncondamodulenotfounderror

Package installed in conda but module not found. How is that possible?


It seems that many people struggle with this problem, but I can't find any answer that works. I think that I am doing everything right but it still doesn't work. I've built my own package and installed it in my conda environment. When I do conda list, it turns up in the list, at the end (I've called it zzpackagerps):

...
zlib                      1.2.11            h62dcd97_1010    conda-forge
zstd                      1.4.9                h6255e5f_0    conda-forge
zzpackagerps              0.0.1                     dev_0    <develop>

Now when I run python, in this environment (py39), and try to import the package, I get the infamous ModuleNotFoundError:

(py39) s:\Sources>python
Python 3.9.4 | packaged by conda-forge | (default, May 10 2021, 22:10:34) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import zzpackagerps
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'zzpackagerps'
>>>

How is this possible? Or, more importantly, how do I get this to work?
(by the way: running on Windows)


Solution

  • One possible issue is that the package name may not be identical to the module name. If you locate the site-packages where the package is installed, you can try looking at the folder structure and where there are __init__.py files defined.