# Adding Custom Python Packages

**URL:** <https://discuss.saleae.com/t/adding-custom-python-packages/2057>\
**Category:** Extensions\
**Created:** [January 19, 2023, 11:48pm UTC](https://discuss.saleae.com/t/adding-custom-python-packages/2057 "2023-01-19T23:48:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fkbokovi](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@fkbokovi](https://discuss.saleae.com/u/fkbokovi)\
**Post date:** [January 19, 2023, 11:48pm UTC](https://discuss.saleae.com/t/adding-custom-python-packages/2057/1 "2023-01-19T23:48:07Z")

</div>

Hi! I’m building a custom HLA for a project I’m working on. However, I need to add a library that we built ourselves. I added the library folder to the same folder housing all the HLA files and I’m just doing an import like the following:

> from proto.[file].[class] import NodeState

Each time I do this, I’m getting an error saying "Saleae Protocol Decoder error - ModuleNotFoundError(“No module named '[file].[class]”. Is there something I can do? I tried one of the solutions I found on the forum, however, I might’ve implemented it incorrectly since it didn’t work.

Any help would be appreciated!

---

<div class="post-metadata">

**Author:** ![timreyes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.saleae.com/timreyes/32/108_2.png) [@timreyes](https://discuss.saleae.com/u/timreyes)\
**Post date:** [January 20, 2023, 11:30pm UTC](https://discuss.saleae.com/t/adding-custom-python-packages/2057/2 "2023-01-20T23:30:41Z")

</div>

@fkbokovi Thanks for writing in, and sorry for the trouble with that. Can you confirm if you’ve tried the solution that Mark shared below?

> [@Import other libraries in HLA](https://discuss.saleae.com/t/import-other-libraries-in-hla/1486):
>
> Hi, I am trying to import some libraries in the HLA. Easily accomplished, or so I thought, by Putting a lib folder next to my script pip install -r requirements.txt --target lib sys.path.append(str(Path(\_\_file\_\_).parent.absolute() / 'lib')) And it is in fact easily accomplished. But the trouble apparently starts when the module I import wants to import something else. It seems all second level imports fail. HighLevelAnalyzer.py", line 21, in \<module\> from construct import Struct File…

---

<div class="post-metadata">

**Author:** ![fkbokovi](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@fkbokovi](https://discuss.saleae.com/u/fkbokovi)\
**Post date:** [January 24, 2023, 7:21pm UTC](https://discuss.saleae.com/t/adding-custom-python-packages/2057/3 "2023-01-24T19:21:32Z")

</div>

Apologies for the late response, I haven’t been in the office for a bit. I will try that right away. I’ve never used requirements.txt before so I’m gonna figure that out right now and try it out and get back to you.

---

<div class="post-metadata">

**Author:** ![fkbokovi](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@fkbokovi](https://discuss.saleae.com/u/fkbokovi)\
**Post date:** [January 24, 2023, 8:51pm UTC](https://discuss.saleae.com/t/adding-custom-python-packages/2057/4 "2023-01-24T20:51:39Z")

</div>

Alright I tried that solution and I’m still not able to get it to work. I first tried it with my lib folder in the same directory holding the hla.py and I get the following error, "Saleae Protocol Decoder error - ModuleNotFoundError(“No module named ‘google’”):

```auto
 File "C:\Program Files\Logic\resources\windows\pythonlibs\lib\site-packages\saleae\_module_space.py", line 251, in load_module
    self._inner_loader.exec_module(module)

  File "C:\Git\VI Projects\Saleae vicom protocol decoder\Saleae Protocol Decoder\HighLevelAnalyzer.py", line 9, in <module>
    from lib.python.proto.nextbot.node_pb2 import NodeState

  File "C:\Git\VI Projects\Saleae vicom protocol decoder\Saleae Protocol Decoder\lib\python\proto\nextbot\node_pb2.py", line 5, in <module>
    from google.protobuf.internal import builder as _builder

```

When I tried with the right outside that directory, it can’t find the file to import from.

---

<div class="post-metadata">

**Author:** ![timreyes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.saleae.com/timreyes/32/108_2.png) [@timreyes](https://discuss.saleae.com/u/timreyes)\
**Post date:** [January 26, 2023, 1:55am UTC](https://discuss.saleae.com/t/adding-custom-python-packages/2057/5 "2023-01-26T01:55:51Z")

</div>

@fkbokovi Hm… let me forward this over to our software team. We’ll be in touch.

---

<div class="post-metadata">

**Author:** ![fkbokovi](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@fkbokovi](https://discuss.saleae.com/u/fkbokovi)\
**Post date:** [January 27, 2023, 7:49pm UTC](https://discuss.saleae.com/t/adding-custom-python-packages/2057/6 "2023-01-27T19:49:56Z")

</div>

Alright, I figured out my issue! The way I created my requirements.txt file was incorrect so I my imports weren’t working correctly.

Thanks for your help!
