question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

file_smart_open missing mode 'rb' caused error

See original GitHub issue

Line 668 in def file_smart_open(fname, mode='rb', encoding=None, errors=DEFAULT_ERRORS) in smart_open_lib.py

try:  # TODO need to fix this place (for cases with r+ and so on)
        raw_mode = {'r': 'rb', 'w': 'wb', 'a': 'ab'}[mode]
except KeyError:
        raw_mode = mode

Should include r+ cases. Otherwise, when mode == ‘rb’, this will cause KeyError

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
menshikh-ivcommented, Dec 21, 2017

I tried to reproduce this (for py27 and py36 versions), but I see no bug, everything is working fine.

versions:

smart-open==1.5.5
gensim==3.2.0
import gensim.downloader as api

model = api.load("glove-twitter-25")
model.most_similar("hello")  # works fine


# save model
model.save("input_model.p")

# load without mmap
loaded_model = model.load("input_model.p")
loaded_model.most_similar("hello")  # works fine


# load with mmap
loaded_model = model.load("input_model.p", mmap="r")
loaded_model.most_similar("hello")  # works fine

For this reason, I close this issue.

2reactions
cosmoschen94commented, Dec 17, 2017

I was trying to load a pickle file from my local file system by using model = KeyedVectors.load('input_model.p', mmap='r') and then KeyError was caught, which prevents me from loading the model

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rails, production-env, "Object is not missing constant"
When I've gotten this error, it's because there's an error in an inner class/module that's inside the class/module mentioned in the error.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found