I have pickled an object in a Mac env and the following works on Mac:
import pickle
file_path = r"embeddings_stft.sav"
try:
with open(file_path, "rb") as file:
print("File opened successfully!")
data = pickle.load(file)
print("Data loaded successfully!")
except Exception as e:
print(f"An error occurred: {e}")
But on Windows, although the file can be read with file.read(), pickle.load() throws the following:
[WinError 32] The process cannot access the file because it is being used by another process: ‘C:UsersUserAppDataLocalTemptmpjw7mmzn2tmp.ann’
I don’t think it has anything to do with cross-platform unpickling issues. On Mac, I’ve tried unpickling it in different Python versions from the one in which it was pickled and that worked fine, so that’s not it either. The problem seems to be something Windows-specific regarding how pickle.load() creates/interacts with temp files.
I’ve also tried file locking with msvcrt so no other processes should be able ot read from it while I am doing so here, but I that didn’t work either.