Skip to content

Use OS-independent path for generated figure - #162

Open
AndreyBunchuk wants to merge 1 commit into
marceloprates:mainfrom
AndreyBunchuk:fix/platform-independent-fig-path
Open

Use OS-independent path for generated figure#162
AndreyBunchuk wants to merge 1 commit into
marceloprates:mainfrom
AndreyBunchuk:fix/platform-independent-fig-path

Conversation

@AndreyBunchuk

Copy link
Copy Markdown

Fix generated map path on Windows

Problem

When running PrettyMaps on Windows, a FileNotFoundError occurs when trying to open the generated map file:

FileNotFoundError: [Errno 2] No such file or directory: '/tmp/generated_map.png'

The error occurs in app.py when opening the generated file:

with open(fig_path, "wb") as f:

The hardcoded /tmp/ path is Unix-specific and does not work correctly on Windows.

Solution

Replaced the hardcoded path with an OS-independent temporary directory:

fig_path = os.path.join(tempfile.gettempdir(), "generated_map.png")

This uses the appropriate temporary directory for the operating system.

Result

The map generation and download functionality now works correctly on Windows while remaining compatible with Unix-based systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant