👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!
I am getting an interesting error while trying to use Unpickler.load()
, here is the source code:
open(target, "a").close()
scores = {};
with open(target, "rb") as file:
unpickler = pickle.Unpickler(file);
scores = unpickler.load();
if not isinstance(scores, dict):
scores = {};
Here is the traceback:
Traceback (most recent call last):
File "G:pythonpenduuser_test.py", line 3, in <module>:
save_user_points("Magix", 30);
File "G:pythonpenduuser.py", line 22, in save_user_points:
scores = unpickler.load();
EOFError: Ran out of input
The file I am trying to read is empty. How can I avoid getting this error, and get an empty variable instead?
👻 Read also: what is the best laptop for engineering students?
We hope this article has helped you to resolve the problem. Apart from Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?, check other ast Python module-related topics.
Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.
By the way, this material is also available in other languages:
- Italiano Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- Deutsch Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- Français Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- Español Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- Türk Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- Русский Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- Português Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- Polski Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- Nederlandse Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- 中文 Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- 한국어 Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- 日本語 Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- हिन्दी Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
Warsaw | 2023-02-07
Simply put and clear. Thank you for sharing. Why do I get “Pickle – EOFError: Ran out of input” reading an empty file? and other issues with traceback Python module was always my weak point 😁. I am just not quite sure it is the best method
San Francisco | 2023-02-07
Simply put and clear. Thank you for sharing. Why do I get “Pickle – EOFError: Ran out of input” reading an empty file? and other issues with code Python module was always my weak point 😁. Checked yesterday, it works!
Paris | 2023-02-07
Simply put and clear. Thank you for sharing. Why do I get “Pickle – EOFError: Ran out of input” reading an empty file? and other issues with Python functions was always my weak point 😁. Will get back tomorrow with feedback