So, your error is related to Python project dependences in UiPath Studio. Because if you run test.py using your Python environment it works. Also, if you delete import rows, test.py works in UiPath Studio too.
Let’s say this python project’s dependencies aren’t visible to your UiPath project.
Instead of copying your .py file from Python project and pasting it in your UiPathStudio, try to indicate .py original path. I mean, it’s located inside your Python project path. Example: C:/Users/Gustavo/PycharmProjects/TestProject/test.py
This can work because in that directory the environment is set and has everything you need to run.
Please, try it and let me know.