External Package Puzzle For Dependency Apps

I have APP1 running 3.10 which imports an external package called “mysql.connector”. When this app is run standalone everything works as expected. APP1 contains a server module with the following lines at the top :

import anvil.server
import anvil.secrets
import mysql.connector
import time

I then add APP1 as a dependency inside another app, APP2. When I run APP2, I get this error :

ModuleNotFoundError: No module named 'mysql'

and it points to the line inside APP1 that imports mysql.connector, giving the impression that APP1 can now no longer reference the package as its a dependency rather than stand alone.

So - do I need to install the package on APP2 as well as APP1? Kind of seems daft to have to modify the host app should the dependency app require mode packages as time goes on.

Note mysql.connector is just one example (I know it’s included in other default 3.10 settings).

You need to make sure that the environment for app2 has everything from the environment in app1.

When app2 imports the code from app1, it needs to run in an environment that includes all the packages required by both app1 and app2.

1 Like

Makes sense, I suppose.

I was hoping that if one dependency app suddenly required a new package, I wouldn’t have to go around what could be many primary apps (mostly required because I can’t have multiple domains pointing to the same app) and update the dependencies.

Hardly the end of the world :face_with_diagonal_mouth:

And, of course, I could always bite the bullet and give this a go :