No stripe module in docker?

What I’m trying to do:
Getting the stripe tutorial app running locally.

What I’ve tried and what’s not working:
git clone ssh://<email>@anvil.works:2222/<key>.git stripe
docker run -v $PWD/stripe:/apps/MainApp -p 3030:3030 anvilworks/anvil-app-server

Locally, it runs (no DB) but I get:

Just a guess, but you might want to try installing the stripe library from pypi in your container.

Thank you @owen.campbell
I still struggle with the Dockerfile so I tried with the stock image and thought it was present in it.

No, the stock image only has the instructions to install the anvil server itself. Any other package you need available has to be added.

have a look at this thread:

Yes, I’ve read it. thank you again for having posted it, it helped me with the Dockerfile and docker-compose.
Does the python stripe module is enough in requirements?
If yes, it means, I must be able to run docker-compose without the user error.

I don’t know. I’ve not tried it. But my guess would be that just installing the usual stripe package is sufficient. (You can see it listed as one of the packages available on the hosted service at Anvil Docs | List of Packages)

I built the image with stripe and docker run it, the error remains the same.
It misses a stripe.checkout module.

Can you confirm that you’ve also included lines in your Dockerfile to install from requirements.txt? Those aren’t included in the stock image but they are shown in the example I linked to above.

Yes:

COPY ./requirements.txt ./
RUN pip install -r requirements.txt

and requirements.txt

anvil-app-server
stripe

so my local image has both.

Could stripe-checkout be an Anvil module?

Because in Pypi, there’s no stripe-checkout, nor in the list of packages above.

EDIT: hmmm, I guess it should be in the stock image since it’s in its source: anvil-runtime/checkout.js at master · anvil-works/anvil-runtime · GitHub

There’s no stripe-checkout in your error, either. That’s complaining that it can’t import stripe.checkout which is definitely part of the stripe package.

You’re right.
I don’t get what is missing then.

Another guess - that looks like an old tutorial. Is it perhaps using the Python 2 environment? If so, I’ve no idea how that might work locally. It’s definitely not where you’re installing stripe.

In Dockerfile, to be sure it’s installed I tried:

COPY ./requirements.txt ./
RUN pip install stripe
RUN pip install anvil-app-server 
# -r requirements.txt
RUN anvil-app-server || true

still the same issue

Initially I’ve done the tutorial from scratch in Python 3.

SSHing in the container, stripe is present:

pip list
WARNING: The directory '/home/user/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
Package            Version
------------------ ---------
anvil-app-server   1.6.5
anvil-uplink       0.3.40
certifi            2021.10.8
charset-normalizer 2.0.12
cli-helpers        2.2.1
click              8.1.2
configobj          5.0.6
future             0.18.2
idna               3.3
pendulum           2.1.2
pgcli              3.4.1
pgspecial          1.13.1
pip                22.0.4
progressbar2       4.0.0
prompt-toolkit     3.0.29
psutil             5.9.0
psycopg2           2.9.3
pychrome           0.2.3
Pygments           2.12.0
python-dateutil    2.8.2
python-utils       3.1.0
pytzdata           2020.1
requests           2.27.1
setproctitle       1.2.3
setuptools         58.1.0
six                1.16.0
sqlparse           0.4.2
stripe             2.74.0
tabulate           0.8.9
urllib3            1.26.9
wcwidth            0.2.5
websocket-client   1.3.2
wheel              0.37.1
ws4py              0.5.1

The clone link you pasted is for an app using Python 2. I suspect that needs changing before it will run in the app server.

I’m guessing you have the code for that locally, so you should be able to change the runtime in anvil.yaml

Hi @phm

What Stripe tutorial are you cloning here? Stripe Checkout is a card capture library – it’s the form the user types their card into – so the stripe.checkout module is available only on the client-side. Are you perhaps trying to import it on the server?

(PS: you might want to change your forum username to something more helpful :slight_smile: You should be able to do it from the menus on the top right.)

Sorry, I don’t get it. I git cloned my stripe project I made from scratch following the tutorial.
Here is my version (my previous link was not the tutorial) : Anvil | Login

When I grep locally it’s on the client:

./client_code/Form1/__init__.py:import stripe.checkout
./client_code/Form1/__init__.py:    c = stripe.checkout.charge(amount=999,

It simply stops at the import, there’s no local stripe.checkout local module, only in the project on Anvil.Works so I guess in the hosted Anvil runtime:
image

Can’t change username BTW:
image

Can your confirm that the stripe service is enabled on that app?

(either look in the left hand sidebar in the ide, or read anvil.yaml locally)

1 Like

It’s setup on the app:
image

and in the local anvil.yaml: - source: /runtime/services/stripe.yml

but I can’t find any runtime/ on the project clone, nor in the container.

Then I’m out of ideas and guesses. :frowning_face:

Here’s what I get from a git clone (the CRUDnews tutorial i made):
image

No runtime/ or tables.yml anywhere
I guess my database issue and the stripe issue are linked to this missing runtime/

When you git clone ssh://<email>@anvil.works:2222/<key>.git do you get a runtime/ folder locally?

.
EDIT:
I wonder if this line shouldn’t be services-core for the root, according to the structure of the server.
Or if it’s only a client module, maybe the adding stripe in node_modules?