# Building addons make.py error "ModuleNotFoundError: No module named 'gramps'"

**URL:** <https://gramps.discourse.group/t/building-addons-make-py-error-modulenotfounderror-no-module-named-gramps/5110>\
**Category:** Development\
**Created:** [March 14, 2024, 12:41pm UTC](https://gramps.discourse.group/t/building-addons-make-py-error-modulenotfounderror-no-module-named-gramps/5110 "2024-03-14T12:41:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![codefarmer](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@codefarmer](https://gramps.discourse.group/u/codefarmer)\
**Post date:** [March 14, 2024, 12:41pm UTC](https://gramps.discourse.group/t/building-addons-make-py-error-modulenotfounderror-no-module-named-gramps/5110/1 "2024-03-14T12:41:51Z")

</div>

System: Ubuntu 22.04.4 LTS running on WSL on Windows 10 with a successful build of Gramps 5.2.0 from source. However, this is the first time I’m building addons (gramps52 branch) and running into an error with the ‘init’ command to make.py:

```python
~/dev/addons-source$ GRAMPSPATH=/home/codefarmer/dev/gramps LANGUAGE='en_US.UTF-8' python3 make.py gramps52 init AllNamesQuickview
make.py: LANGUAGE is en_US.UTF-8... good!
Traceback (most recent call last):
  File "/home/codefarmer/dev/addons-source/make.py", line 214, in <module>
    from gramps.gen.plug import make_environment, PTYPE_STR
ModuleNotFoundError: No module named 'gramps'

```

The error is on [L214 of make.py](https://github.com/gramps-project/addons-source/blob/5eafdf9d85167c28480655bc9d261e7634ec544b/make.py#L214) which is accessing Gramps modules. I’ve set GRAMPSPATH to point to the root of the gramps source folder. What am I overlooking?

BTW, I get the same error in the MSYS development environment.

---

<div class="post-metadata">

**Author:** ![Nick-Hall](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/nick-hall/32/95_2.png) [@Nick-Hall](https://gramps.discourse.group/u/Nick-Hall)\
**Post date:** [March 14, 2024, 2:40pm UTC](https://gramps.discourse.group/t/building-addons-make-py-error-modulenotfounderror-no-module-named-gramps/5110/2 "2024-03-14T14:40:51Z")

</div>

This looks like a bug. I’ll investigate.

I only tend to use the _build_ and _listing_ options myself, but _init_, _update_ and _compile_ are also important.

---

<div class="post-metadata">

**Author:** ![codefarmer](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@codefarmer](https://gramps.discourse.group/u/codefarmer)\
**Post date:** [March 14, 2024, 2:53pm UTC](https://gramps.discourse.group/t/building-addons-make-py-error-modulenotfounderror-no-module-named-gramps/5110/3 "2024-03-14T14:53:07Z")

</div>

Thanks for your time on this, @Nick-Hall . Because it’s the first time I’m building addons I am not sure which of the available make commands are to be used, and in what order. I was simply going by intuition that `init` has to be the first step. `Build` command works without errors, although `listing` command fails and I wonder if it is because things aren’t initialized properly?

```python
~/dev/addons-source$ GRAMPSPATH=/home/codefarmer/dev/gramps LANGUAGE='en_US.UTF-8' python3 make.py gramps52 listing AllNamesQuickview
make.py: LANGUAGE is en_US.UTF-8... good!
Building listing for 'lt'...
Traceback (most recent call last):
  File "/home/codefarmer/dev/addons-source/make.py", line 864, in <module>
    fp_out = open(r("../addons/%(gramps_version)s/listings/") +
FileNotFoundError: [Errno 2] No such file or directory: '../addons/gramps52/listings/addons-lt.json'

```

---

<div class="post-metadata">

**Author:** ![codefarmer](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@codefarmer](https://gramps.discourse.group/u/codefarmer)\
**Post date:** [March 14, 2024, 2:59pm UTC](https://gramps.discourse.group/t/building-addons-make-py-error-modulenotfounderror-no-module-named-gramps/5110/4 "2024-03-14T14:59:23Z")

</div>

OK, ignore the error on `listing` command - just needed to create the “listings” directory manually, i.e. `../addons/gramps52/listings`.

---

<div class="post-metadata">

**Author:** ![Nick-Hall](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/nick-hall/32/95_2.png) [@Nick-Hall](https://gramps.discourse.group/u/Nick-Hall)\
**Post date:** [March 14, 2024, 6:11pm UTC](https://gramps.discourse.group/t/building-addons-make-py-error-modulenotfounderror-no-module-named-gramps/5110/5 "2024-03-14T18:11:15Z")

</div>

Actually, I think that there is a problem with the _listing_ option when a single addon is specified.

There is also some tidying up required - black formatting and removing duplicate and redundant code.

---

<div class="post-metadata">

**Author:** ![Nick-Hall](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/nick-hall/32/95_2.png) [@Nick-Hall](https://gramps.discourse.group/u/Nick-Hall)\
**Post date:** [March 14, 2024, 10:50pm UTC](https://gramps.discourse.group/t/building-addons-make-py-error-modulenotfounderror-no-module-named-gramps/5110/6 "2024-03-14T22:50:18Z")

</div>

I’ve fixed the _init_ command. There wasn’t a problem with the _listing_ command.

The workflow for translations is to first run _init_ to create the `pot` file:

```sh
python make.py gramps52 init MyAddon

```

Then run _init_ again with a language to create the corresponding `po` file:

```sh
python make.py gramps52 init MyAddon fr

```

Finally the `po` files can be compiled into `mo` files using:

```sh
python make.py gramps52 compile MyAddon

```

When changes are made to an addon, we run _build_ to create the `tgz` file:

```sh
python make.py gramps52 build MyAddon

```

and then the listings can be updated using:

```sh
python make.py gramps52 listing all

```

Set your `GRAMPSPATH` environment variable to point to your Gramps source code.

I’ve never used any of the other commands myself. The _as-needed_ looks useful. I’ll look at creating some functions to remove some of the duplicate code.

---

<div class="post-metadata">

**Author:** ![codefarmer](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@codefarmer](https://gramps.discourse.group/u/codefarmer)\
**Post date:** [March 14, 2024, 11:23pm UTC](https://gramps.discourse.group/t/building-addons-make-py-error-modulenotfounderror-no-module-named-gramps/5110/7 "2024-03-14T23:23:30Z")

</div>

Thanks, @Nick-Hall . Your change resolved the error, and the workflow description is very helpful.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/gramps/original/1X/2ac1e712b7adf612e31ca08a55419f4cf37c0158.png) [@system](https://gramps.discourse.group/u/system)\
**Post date:** [April 13, 2024, 11:24pm UTC](https://gramps.discourse.group/t/building-addons-make-py-error-modulenotfounderror-no-module-named-gramps/5110/8 "2024-04-13T23:24:19Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
