App runs perfectly fine locally, but breaks when deployed (even with requirements.txt provided)


So I’m building a tool for an analysis. The tool uses primarily pandas, numpy and a custom library that I created that is on PyPi called “PayEquity.”

My tool was working perfectly fine when I deployed it, then I started getting errors a few days later. I get some error from statsmodel.

TypeError: loop of ufunc does not support argument 0 of type float which has no callable sqrt method

This error usually happens when a dataframe is not all float. However, this error only happens when deployed, and the code runs perfectly fine locally so I don’t know how to reproduce it or fix it.

The code for the tool is here: GitHub - scunden/payX: Pay Equity Tool

I am running out of ideas for how to fix this. I suspect this is some sort of package version mismatch that is causing misbehaviors. However, I have a requirements.txt file so I don’t know how this could happen. Any help would be greatly appreciated!

I can see that you are using a custom library called PayEquity. This library is not installed on the production server, so you are getting an error when you try to use it.

To fix this, you need to install the PayEquity library on the production server. You can do this by running the following command:
pip install PayEquity

Once you have installed the PayEquity library, you should be able to run your tool without any errors.

Here are some other things you can try:

  • Check the versions of the packages you are using. Make sure that they are the same versions that you are using locally.
  • Try running your tool in a virtual environment. This will help to isolate the dependencies of your tool and make it easier to troubleshoot problems.

The library is part of the requirement.txt file and I can see through the logs that it is getting properly installed. Moreover, when I run my code locally, it is ran in a virtual environment. My requirement.txt file is created from that same environment. Locally, there are absolutely no errors when running the tool.

I even tried uninstalling my custom package, and just placing the physical folder in my streamlit too repository and accessing them relatively. Again, locally it runs without any issues on a virutal environment. But as soon as it is deployed, I get an error in statsmodel.

Is there a way to export the streamlit environment file? i.e., create a requirements.txt from the streamlit app that is deployed, so that I can see exactly what is being installed, and how it compares to what I gave it?

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