Somoclu library has problems installing in heroku

First of all, thank you for being part of this beautiful community.

Explaining my problem. When I implemented my application in heroku, the following error appears when trying to install the somoclu library. locally I have no operational problems with any of the libraries.

I have tried to solve this problem by downloading the previous versions of the used libraries and the problem is still present.

I attach the libraries I am using and a screenshot of the error in heroku

matplotlib == 3.2.2
numpy == 1.18.5
pandas == 1.0.5
plotly == 4.8.2
streamlit == 0.62.1
somoclu == 1.7.5
scikit-learn == 0.23.1

Hello @eosovngas, welcome to the forum!

Well, this doesn’t seem to be related to streamlit but somoclu which uses numpy in its setup file.

Even if numpy is written before somoclu in your requirements.txt, it won’t be ready to be used yet in somoclu’s And the reason why it worked locally is maybe because numpy was already present in your python environment when you installed somoclu.

To fix the issue you’ll have to pip install numpy before installing somoclu.


Thank you very much for answering my problem, my question is where I install numpy so that I can run somoclu since even though it is first in the list of requirements it keeps throwing the error that is not installed.

The solution that comes to mind is to install it as follows in the file and delete the somoclu library of requirements.txt


import pandas as pd
import numpy as np
import pickle
import streamlit as st
import matplotlib.pyplot as plt
import as px
import os

os.system('pip install somoclu==1.7.5')
import somoclu

file requirements.txt

pandas == 1.0.5  
numpy == 1.18.5   
plotly == 4.8.2
matplotlib == 3.2.2
scikit-learn == 0.23.1 
streamlit == 0.62.1

There should be another, more optimal way to solve the problem since every time is run or the page is refreshed, somoclu would be installed.

this way my works but the page load time is too long, there should be another way to solve this problem.

I leave the url of my app

Unverified, but this suggestion on StackOverflow has a potential solution