I thought that USERPROFILE (in my case is “c:\users\LMM”) will work in the other computer getting the local path, but always the file is generated in mine.
It appears that the issue is related to the usage of the USERPROFILE environment variable, which points to your local user profile directory. When you run your Streamlit app on another computer through the network, it will still reference the USERPROFILE of the machine where the Streamlit app is running.
To make the document saving location dynamic and based on the user’s machine, you can use the os module to get the user’s home directory. Here’s an example of how you can modify your code:
import os
# Get the user's home directory
user_home = os.path.expanduser("~")
# Define the path where you want to save the document
descarga = os.path.join(user_home, 'Downloads')
# Rest of your code
plantilla = f"NDA - {empresa}.docx"
output_path = os.path.join(descarga, plantilla)
doc.save(output_path)
convert(output_path)
By using os.path.expanduser("~"), you will get the user’s home directory path dynamically based on the user’s machine, allowing the document to be saved in their local Downloads directory rather than your own.