ModuleNotFoundError: No module named 'fuujin_lib'

Hi!

I’m trying to develop a python application and package it with nix flakes.
However, I’m having some troubles with importing custom python module.
This is my repo:

commit id c836b50 is from before importing module; as you can see I can run my application:

user@kaktus ~ ((c836b509))> nix run .#fuujin
language = en
debug level = 1
user@kaktus ~ ((c836b509))> 

However, after adding these lines:

    from fuujin_lib.functions import logger
    logger(debug_level=debug_level)

(This is my repo structure:

user@kaktus ~ (main)> tree
.
├── docs
│   └── main.md
├── flake.lock
├── flake.nix
├── fuujin
│   ├── fuujin_lib
│   │   ├── functions.py
│   │   └── __pycache__
│   │       └── functions.cpython-311.pyc
│   ├── __init__.py
│   ├── __main__.py
│   ├── master.py
│   └── __pycache__
│       ├── fnlib.cpython-311.pyc
│       └── master.cpython-311.pyc
├── fuujin.code-workspace
├── LICENSE
├── poetry.lock
├── pyproject.toml
├── README.md
├── result -> /nix/store/rfidgilh6kbyh6hnfaa4wpgz84v1c5mh-fuujin-0.1.0
└── TODO.md

7 directories, 16 files
user@kaktus ~ (main)> 

I get the following error:

user@kaktus ~ (main)> nix run .#fuujin
Traceback (most recent call last):
  File "/nix/store/s2222cjfpvvx5l9i5dg1s08f7ck8d4lg-fuujin-0.1.0/bin/.fuujin-wrapped", line 9, in <module>
    sys.exit(main())
             ~~~~^^
  File "/nix/store/s2222cjfpvvx5l9i5dg1s08f7ck8d4lg-fuujin-0.1.0/lib/python3.13/site-packages/fuujin/master.py", line 27, in main
    from fuujin_lib.functions import logger
ModuleNotFoundError: No module named 'fuujin_lib'
user@kaktus ~ (main) [1]> 

My guess is that it has something to do with entry point in pyproject.toml. Am I right? Can you guys help me out?

Best,
Miro

  1. __init__.py is missing
  2. It’s fuujin.fuujin_lib as far as I can tell
  3. You are committing the pycache, which you shouldn’t
1 Like

Thank you indeed! That helped.

Also, let me kindly ask, is this forum the right place for such questions? Or should I try some python forums?

Best,
Miro

If you are sure your problem is python related, then go to a python community.

If you are sure it’s nix, ask here.

If you are unsure ask in one place, and mention that you are unsure whether you are asking in the right place, and signal that you are ready to move the discussion to another, more appropriate place.

Understood! Thank you for your time!