I follow step by step in : https://geemap.org/notebooks/33_accuracy_assessment/#split-training-and-testing

When the step to download confusion matrix, there is error. I type the code :

import csv
import os

out_dir = os.path.join(os.path.expanduser('~'), 'Downloads')
training_csv = os.path.join(out_dir, 'train_accuracy.csv')
testing_csv = os.path.join(out_dir, 'test_accuracy.csv')

with open(training_csv, "w", newline="") as f:
     writer = csv.writer(f)

with open(testing_csv, "w", newline="") as f:
     writer = csv.writer(f)

Then the error is like this :

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-62-96b0f54cfa85> in <cell line: 8>()
     6 testing_csv = os.path.join(out_dir, 'test_accuracy.csv')
----> 8 with open(training_csv, "w", newline="") as f:
     9     writer = csv.writer(f)
    10     writer.writerows(train_accuracy.getInfo())

FileNotFoundError: [Errno 2] No such file or directory: '/root/Downloads/train_accuracy.csv'

Then I go to the next step with no error. I curious, why the error happen? What is wrong?

  • Are you working with Windows or Linux?
    – Mayo
    Aug 20, 2023 at 20:24
  • I use MX Linux. But, I run using Colab Aug 21, 2023 at 7:08

1 Answer 1


If using Colab, it can use the current working directory rather than the root directory.

out_dir = os.getcwd()
testing_csv = os.path.join(out_dir, 'test_accuracy.csv')

This answer is from the author. Thank you for the author. The answer is in https://github.com/gee-community/geemap/issues/1670

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.