# Import python library with n8nio/n8n:PR-4295-python-code-node : Not found

**URL:** <https://community.n8n.io/t/import-python-library-with-n8nio-n8n-pr-4295-python-code-node-not-found/25709>\
**Category:** Questions\
**Tags:** node\
**Created:** [April 28, 2023, 2:46pm UTC](https://community.n8n.io/t/import-python-library-with-n8nio-n8n-pr-4295-python-code-node-not-found/25709 "2023-04-28T14:46:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![home](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@home](https://community.n8n.io/u/home)\
**Post date:** [April 28, 2023, 2:46pm UTC](https://community.n8n.io/t/import-python-library-with-n8nio-n8n-pr-4295-python-code-node-not-found/25709/1 "2023-04-28T14:46:55Z")

</div>

Hello,

I have created from n8nio/n8n:PR-4295-python-code-node a new image for using Python Node and some customs library…

```auto
FROM n8nio/n8n:PR-4295-python-code-node
WORKDIR /data

COPY requirements.txt requirements.txt

USER root
RUN apk add --update py-pip automake gcc g++ subversion python3-dev
RUN pip3 install -r requirements.txt

```

requirements.txt : Contains “pdfkit”

I build the image, named n8n-python :  
`docker build -t n8n-python -f DockerFile .`

After that, I run it, and open a terminal :  
`python -c "import pdfkit"` =\> OK

At the end, I try to create a Python Node with the “pdfkit”…

```auto
import pyodide_js
await pyodide_js.loadPackage('pdfkit')

```

ERROR: JsException: Error: No known package with name ‘pdfkit’

```auto
import pdfkit

```

ERROR: ModuleNotFoundError: No module named ‘pdfkit’

I have also used the field defining the imported libraries :

```auto
ERROR: Traceback (most recent call last): File "/lib/python3.10/asyncio/futures.py", line 201, in result raise self._exception File "/lib/python3.10/asyncio/tasks.py", line 234, in __step result = coro.throw(exc) File "/lib/python3.10/site-packages/micropip/_micropip.py", line 573, in install await transaction.gather_requirements(requirements) File "/lib/python3.10/site-packages/micropip/_micropip.py", line 333, in gather_requirements await gather(*requirement_promises) File "/lib/python3.10/asyncio/futures.py", line 284, in__await __yield self # This tells Task to wait for completion. File "/lib/python3.10/asyncio/tasks.py", line 304, in__ wakeup future.result() File "/lib/python3.10/asyncio/futures.py", line 201, in result raise self._exception File "/lib/python3.10/asyncio/tasks.py", line 232, in __step result = coro.send(None) File "/lib/python3.10/site-packages/micropip/_micropip.py", line 340, in add_requirement return await self.add_requirement_inner(Requirement(req)) File "/lib/python3.10/site-packages/micropip/_micropip.py", line 432, in add_requirement_inner metadata = await _get_pypi_json(req.name, self.fetch_kwargs) File "/lib/python3.10/site-packages/micropip/_micropip.py", line 48, in _get_pypi_json metadata = await fetch_string(url, fetch_kwargs) File "/lib/python3.10/site-packages/micropip/_compat_in_pyodide.py", line 35, in fetch_string return await (await pyfetch(url, **kwargs)).string() File "/lib/python3.10/pyodide/http.py", line 251, in pyfetch url, await _jsfetch(url, to_js(kwargs, dict_converter=Object.fromEntries)) NameError: name '_jsfetch' is not defined

```

what did I forget ?  
Thanks 😉

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [May 3, 2023, 7:55am UTC](https://community.n8n.io/t/import-python-library-with-n8nio-n8n-pr-4295-python-code-node-not-found/25709/2 "2023-05-03T07:55:00Z")

</div>

Hi @home, that [pull request](https://github.com/n8n-io/n8n/pull/4295) isn’t finalized yet I am afraid. Meaning I am not sure about the current status, and I am also not familiar with this Python package specifically.

Seeing you are using a custom image anyway you could simply consider installing a standard python binary and then run your Python scripts via the Execute Command node here.

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [May 10, 2023, 8:48am UTC](https://community.n8n.io/t/import-python-library-with-n8nio-n8n-pr-4295-python-code-node-not-found/25709/3 "2023-05-10T08:48:25Z")

</div>

@home Could the problem be that the module gets installed for user `root`, but n8n is actually running as user `node`?

Regarding

```auto
import pyodide_js
await pyodide_js.loadPackage('pdfkit')

```

That is nothing you actually have to run yourself. n8n will run that automatically when you write `pdfkit` in the “Python Modules” parameter.

And there is also a new Docker image which you should start to use moving forward. It is the v1 release cancidate one: `docker.n8n.io/n8nio/n8n:1.0.0-rc`

---

<div class="post-metadata">

**Author:** ![JanMrlth1](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/janmrlth1/32/3307_2.png) [@JanMrlth1](https://community.n8n.io/u/JanMrlth1)\
**Post date:** [August 1, 2023, 12:48pm UTC](https://community.n8n.io/t/import-python-library-with-n8nio-n8n-pr-4295-python-code-node-not-found/25709/4 "2023-08-01T12:48:12Z")

</div>

Hi, is there any update on this?

I want to use the ‘cadquery’ libary in a Code node with Python.

I have created a Dockerfile to extend the existing image.

```auto
FROM n8nio/n8n

WORKDIR /data

COPY requirements.txt requirements.txt

USER root

RUN apk add --update py-pip automake gcc g++ subversion python3-dev

RUN pip3 install -r requirements.txt

```

As far as I understand it now, the code node does not use python but Pyodide, so I can not add external packages to that?

What would be the right way to do that today? We run 1.0.5

I can run my custom script using the Execute Command node. How would I hand over my binary data in this case?

thank you!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [October 30, 2023, 12:48pm UTC](https://community.n8n.io/t/import-python-library-with-n8nio-n8n-pr-4295-python-code-node-not-found/25709/5 "2023-10-30T12:48:21Z")

</div>

Closed on October 30, 2023, 12:48pm UTC

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

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [November 3, 2023, 9:09pm UTC](https://community.n8n.io/t/import-python-library-with-n8nio-n8n-pr-4295-python-code-node-not-found/25709/6 "2023-11-03T21:09:10Z")

</div>

@JanMrlth1 You would have to build a Python wheel for that package. You can find information about it here:  
[https://pyodide.org/en/stable/development/new-packages.html#building-python-wheels-out-of-tree](https://pyodide.org/en/stable/development/new-packages.html#building-python-wheels-out-of-tree)
