Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to deploy on heroku : no module named requests #1

Open
tutacrypto opened this issue Jun 10, 2020 · 5 comments
Open

Comments

@tutacrypto
Copy link

tutacrypto commented Jun 10, 2020

Hello,

I got an error : no module named requests, during the installation of lnpay-py when trying to deploy an app on Heroku.
The requests module is in my requirements.txt before lnpay-py.

I contacted Heroku support, and here is what they told me :

"Hi Gustave,

Sorry about that! I completely missed it in your first comment, thank you for clarifying.

Our Python language owner was kind enough to take a look at your situation and I've included the feedback he provided below. Ultimately most likely issue here is that the lnpay-py package is broken.

Python packages can be shipped as either wheels (newer; preferred) or sdists (source distributions). For sdists, when the package is installed, setuptools invokes setup.py as part of the install.

Looking at the package it seems setup.py imports a file that in turn imports requests, meaning that the package actually has not only a run time dependency on requests, but also a build time dependency.

Adding requests to requirements.txt won't help, since during the very first pip install, requests won't yet have been installed when lnpay-py's setup.py is being invoked. The Python ecosystem is partway through devising a way to handle build time dependencies (https://www.python.org/dev/peps/pep-0518/) though in this case the package is just accidentally importing it and doesn't necessarily need it.

To ultimately resolve the issue you'll need to reach out to the the author of the package to see if they can fix the import issue. You can specifically mention that the package maintainer should rework the __version__ import such that it doesn't also import requests during pip install, since the current implementation will break installing into any clean environment, not just Heroku. In addition, the package maintainer should ideally also ship wheels, since they are the preferred package format (and would have wallpapered over this issue too):https://pythonwheels.com/

Does all of that make sense? Please let me know if you have any questions or if I can assist any further!

Thanks,
Lucas"

I don't understand everything, but I hope you and others will! Don't hesitate to tell me if you want me to ask them more information.

@ghost
Copy link

ghost commented Jun 10, 2020

Thanks for reporting all of that. So you're using it as a library in another package and you're having this issue? I'm not python expert but have done several apps this way, with libraries I've created like this, though not deployed them to heroku so that's something to consider here. I've typically deployed them as docker images. Not saying you should have to deploy it as docker, I'll investigate what's going on here and learn from it.

@tutacrypto
Copy link
Author

tutacrypto commented Jun 11, 2020

I'm using lnpay-py as a library in my python app's server (using Flask framework).
Locally everything works fine, it's only when deploying to Heroku cloud provider that I'm having this issue.

Thanks, keep me posted please!

@fiatjaf
Copy link

fiatjaf commented Jun 11, 2020

What if the error is in this line?

from lnpay_py import __version__

Maybe a package shouldn't depend on itself at build time? I'm not sure.

@ghost
Copy link

ghost commented Jun 11, 2020

Yeah that's interesting, I can definitely replace that and see what happens, did that out of habit but I don't think I'm using it elsewhere anyways. I'll try to set up an example heroku project importing this library and play around with it over the next few days.

@Inspector-Butters
Copy link

this is still the case.
I usually have to run a pip install requests before installing lnpay and that works.

but its a pain when deploying to different platforms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants