haj
haj13mo ago

Python 'AttributeError' for certain modules

Hi, Im trying to run a python script in Windmill's UI, but am getting an 'AttributeError' for certain packages such as numpy (example in screenshot). When I run print(numpy), I get the following: <module 'numpy' (<_frozen_importlib_external.NamespaceLoader object at 0x7f28c4de3750>)>. However, I was told by support that I should see the following: <module 'numpy' from '/tmp/windmill/cache/pip/numpy==1.26.1/numpy/__init__.py'>. Could this have something to do with my install/scripts? Would appreciate any help. Thank you.
No description
8 Replies
rubenf
rubenf13mo ago
You will want to share a lot more about your issue including your full script and setup
haj
haj13mo ago
Sharing script that produces 'AttributeError': import numpy as np print(np) list1 = [['1', '1', '1', '9/1/23'], ['2', '1', '0', '9/15/23']] def main(x: str): for i in np.arange(0,len(list1)): print(i) return x @rubenf What would be useful to share in terms of setup?
rubenf
rubenf13mo ago
helm vs docker-compose, pip index, etc, etc you should also look into your cache maybe cleaning up the cache volume could be sufficient
haj
haj13mo ago
Can this be done through the UI in 'Workers'?
rubenf
rubenf13mo ago
only on EE actually not sure anymore, it might be available on CE
haj
haj13mo ago
I was able to resolve this by heading the script in the following way: #requirements: #dependency #numpy==1.24.0 import dependency import numpy as np print(np) def main(x: str): return x However, when I try something similar with module psycopg, I'm not able to successfully import. For example, the following code returns a 'Permission denied' error: # requirements: # dependency # psycopg==3.1.10 import dependency import psycopg print(psycopg) def main(x: str): return x I've also tried importing psycopg2 but get 'AttributeError'. Please let me know if I can share anything else that would be useful. Would appreciate any assistance on this. Thank you.
No description
rubenf
rubenf13mo ago
Permission denied is something wrong with your setup most likely windmill not running as root or with different users on the shared volume
haj
haj13mo ago
Will look into this, thank you.