Install a package from git that requires a compiler

Dear all,

Running my app on Streamlit Cloud I want to use a package from git (GitHub - QuantumPhotonicsLab/readPTU: A Python library to read PTU files from PicoQuant) that requires a compiler ( ‘gcc’ on Linux, ‘clang’ on macOS or ‘vc’ on Windows).

  1. To install the package readPTU I added a line git+URL in requirments.txt. However when trying to import the package I get the import error :
    File “/home/appuser/venv/lib/python3.7/site-packages/readPTU/readPTU.py”, line 33, in from ._readTTTRRecords_HHT2_HH2 import ffi, lib
    This file should have been created when running the setup.py of ReadPTU if the right compiler was present.
    I’m not sure what to add to packages.txt so that the installation of the package runs fine on the cloud. I tried adding “clang”, “gcc” or “cmakes” but none of those worked. Can you help me figure it out?

Thanks for your help!

1 Like

Hi @Mathias, welcome to the Streamlit community!

I would try build-essential in the packages.txt file, which will install a few of those system-level dev packages.

Best,
Randy

Hi @randyzwitch, thanks for your answer. Unfortunatly it did’t work. It seems that the packages is not being installed properly. It works fine on any computer if I clone the repo and run the setup.py file from shell. Is there a way to do something similar ou the cloud?

Best,

Mathias

Can you post a link to the repo you’re trying to deploy from?

1 Like

Hi @Mathias ,
could you please post the full stack trace of your error ?

1 Like

Hi @anth2o, here is the full report:

ModuleNotFoundError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs.

Traceback:

File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/script_runner.py", line 354, in _run_script
    exec(code, module.__dict__)File "/app/fitmydata/app.py", line 74, in <module>
    exec(open('fit_g2.py').read())File "<string>", line 18, in <module>File "/app/fitmydata/from_PTU.py", line 13, in <module>
    from readPTU import PTUfile, PTUmeasurementFile "/home/appuser/venv/lib/python3.7/site-packages/readPTU/__init__.py", line 1, in <module>
    from .readPTU import *File "/home/appuser/venv/lib/python3.7/site-packages/readPTU/readPTU.py", line 33, in <module>
    from ._readTTTRRecords_HHT2_HH2 import ffi, lib

@randyzwitch unfortunatly my repo is not ready to go public yet. Do you know any public repo that uses a package that requires a compiler so that I can check what they do differently?

Best regards,

Mathias

@Mathias I think this issue is a common issue of the readPTU package: Import errors, and can't find _readTTTRRecords_build.py to compile dynamic library · Issue #3 · QuantumPhotonicsLab/readPTU · GitHub

I actually found the solution. The issue is that GitHub - QuantumPhotonicsLab/readPTU: A Python library to read PTU files from PicoQuant can’t work when installed through pip install . because the compiled files are writtent in the readPTU folder after the package has been installed in your Python site-packages folder.
I opened a PR to do the compile in a build step prior to the installation of the package, so that the compiled files are included in the final Python package installed on your system.

1 Like

Thanks @anth2o! This solves the problem.

Bravo et merci,

Mathias