Python sdk Activation Fails

When trying to activate the python sdk according to the tutorial by importing imfusion, I get the error that the api endpoint is not reachable:

ImportError: Could not activate license. Please check that license server at https://api.imfusion.com can be reached. A proxy can be set with the HTTPS_PROXY environment variable.

I have the license stored in the right environment variable and I am not behind a (corporate) proxy. When trying to manually connect to the endpoint I am not allowed to make the connection.

Is there anything I have to set?
Thanks in advance!

Hi Eric,

thanks for reaching out.
The error message that you are seeing is not necessarily related to a proxy. The message itself is the generic failure message and the part about the proxy is meant as a suggestion for what to check. We will improve it in the next release.

Now let’s try and fix this for you. If you are not behind a proxy, this error could also indicate a mismatch between license and product type. Did you get the Python SDK from PyPI or did you get it with an installer from us? The license keys for the installer and PyPI versions are mutually incompatible.
If you happen to have both on your system, make sure that you are loading the expected version. You can check your import locations and order by running `import sys; print(*sys.path, sep=“\n”).

Cheers,
Ilja

Hi Ilja,

thank you very much for your answer. I followed the tutorial suggesting to install the SDK using PyPI after getting the license key for the python SDK from your shop. I also have ImFusion Labels installed and registered on my machine. Could this have an influence on the registration process?

Thank you in advance!
Best,
Eric

Hi Eric,

the Python SDK is using a different license than Labels, but one machine can have multiple licenses for different products.

Could you check whether you have the HTTPS_PROXY (or https_proxy) environment variable set? Maybe it tries to use an invalid proxy. Can you also try curl https://api.imfusion.com/? We are using libcurl internally, so it is affected by the same environment variables than curl.

Best,
Markus

Hi Markus,

thanks for your message! I got the error, that the license has been activated too often. I aquired a new key that worked.
But I have a question: Does it activate the license each time I try to import imfusion? Background is that I want to use the ImFusion Python SDK within a docker-container.

In the case of docker, the license is indeed activated every time you restart the container. In general we recommend to activate the license on the host and map it into the container:

  1. lsblk -no UUID $(df -P / | awk 'END{print $1}') > /var/lib/ImFusion/Suite/disk-token
  2. Start container with -v /var/lib/ImFusion/Suite:/var/lib/ImFusion/Suite
  3. import imfusion inside the container

This should create the licensev2.ini inside /var/lib/ImFusion/Suite on the host and as long as you use the -v argument to start the container, it won’t need to re-activate the license.

In docker, you might also have issues with the OpenGL context. You can either use the nvidia/cudagl:11.4.1-runtime with the nvidia docker runtime or you can use a software renderer:

FROM python:3.12-slim

RUN apt-get update && \
    apt-get install -y \
        libopengl0 \
        libegl1 \
        libgl1 \
        libglvnd0 \
        libglib2.0-0

RUN pip install imfusion-sdk

ENV EGL_PLATFORM surfaceless

ENTRYPOINT ["python", "-c", "import imfusion;print(imfusion.info())"]

We will add more detailed instructions for docker to our documentation soon.

Thank you very much, this is very helpful!
That solves the Issue for me. I had OpenGL probelms with docker and accidentally activated the license at every fix. Once the problem was solved I must have exceeded the activation limit.
Now it should work.
Thanks again!