Skip to main content
Solved

Add package from github url

  • February 5, 2026
  • 3 replies
  • 24 views

RAMBOURG Pierre
Committed

Hello everyone.

 

I’m looking to use a package from github the same way I already use it in requirements.txt for Cognite Function.

The format is :

git+https://<token>@<url>@<branch>

When I add this line in settings :

Error during booting up

Traceback (most recent call last):
  File "/lib/python3.12/site-packages/packaging/requirements.py", line 35, in __init__
    parsed = _parse_requirement(requirement_string)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/packaging/_parser.py", line 64, in parse_requirement
    return _parse_requirement(Tokenizer(source, rules=DEFAULT_RULES))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/packaging/_parser.py", line 82, in _parse_requirement
    url, specifier, marker = _parse_requirement_details(tokenizer)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/packaging/_parser.py", line 126, in _parse_requirement_details
    marker = _parse_requirement_marker(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/packaging/_parser.py", line 147, in _parse_requirement_marker
    tokenizer.raise_syntax_error(
  File "/lib/python3.12/site-packages/packaging/_tokenizer.py", line 165, in raise_syntax_error
    raise ParserSyntaxError(
packaging._tokenizer.ParserSyntaxError: Expected end or semicolon (after name and no valid version specifier)
    git+https://<token>@<url>@<branch>
       ^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/lib/python3.12/site-packages/micropip/_commands/install.py", line 142, in install
    await transaction.gather_requirements(requirements)
  File "/lib/python3.12/site-packages/micropip/transaction.py", line 55, in gather_requirements
    await asyncio.gather(*requirement_promises)
  File "/lib/python3.12/site-packages/micropip/transaction.py", line 62, in add_requirement
    return await self.add_requirement_inner(Requirement(req))
                                            ^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/packaging/requirements.py", line 37, in __init__
    raise InvalidRequirement(str(e)) from e
packaging.requirements.InvalidRequirement: Expected end or semicolon (after name and no valid version specifier)
    git+https://<token>@<url>@<branch>
       ^

Do you have a workaround or a way to fix parsing rules ?

Regards,

Pierre Rambourg

 

Best answer by Anders Hafreager

Hi,

This is unfortunately not supported in the normal way like this. But you can download the wheel file to the local disk using requests, and install it from local disk (or have the wheel file as a CDF file):

# Alternative 1:
file_external_id = "package-1.0.0-py3-none-any.whl"
client.files.download_to_path(external_id=file_external_id, path=file_external_id)

# Alternative 2:
import requests
from pathlib import Path
import micropip

# Download file directly from GitHub
url = (
"https://raw.githubusercontent.com/OWNER/REPO/main/dist/package-1.0.0-py3-none-any.whl"
)

# Download wheel
resp = requests.get(url)
resp.raise_for_status()

Path(file_external_id).write_bytes(resp.content)

# Install from local filesystem (Pyodide / emfs)
await micropip.install(f"emfs:./{file_external_id}")

The code may not be 100% correct, but illustrates the idea. Let me know if you can make it work!

3 replies

Anders Hafreager
Practitioner

Hi,

This is unfortunately not supported in the normal way like this. But you can download the wheel file to the local disk using requests, and install it from local disk (or have the wheel file as a CDF file):

# Alternative 1:
file_external_id = "package-1.0.0-py3-none-any.whl"
client.files.download_to_path(external_id=file_external_id, path=file_external_id)

# Alternative 2:
import requests
from pathlib import Path
import micropip

# Download file directly from GitHub
url = (
"https://raw.githubusercontent.com/OWNER/REPO/main/dist/package-1.0.0-py3-none-any.whl"
)

# Download wheel
resp = requests.get(url)
resp.raise_for_status()

Path(file_external_id).write_bytes(resp.content)

# Install from local filesystem (Pyodide / emfs)
await micropip.install(f"emfs:./{file_external_id}")

The code may not be 100% correct, but illustrates the idea. Let me know if you can make it work!


RAMBOURG Pierre
Committed

Hi ​@Anders Hafreager 
 

Apart from dependency conflicts and the lack of certain libraries due to the error: Can't find a pure Python 3 wheel for... by micropip.

That seems like a good workaround. I need to refine the solution, but it's a very good idea, thank you !


Anders Hafreager
Practitioner

Yeah, our Streamlit and Jupyter Notebook solution is based on Pyodide which has certain limitations on what packages can be run unless they are pure Python 3 wheels packages.

 

Let me know if there are other obstacles on the way.