piskvorky / gensim

Topic Modelling for Humans
https://radimrehurek.com/gensim
GNU Lesser General Public License v2.1
15.65k stars 4.37k forks source link

AttributeError: 'dict' object has no attribute '__NUMPY_SETUP__' #3225

Closed icanhasmath closed 1 year ago

icanhasmath commented 3 years ago

Building gensim from source on Python 3.9 I consistently get this error:

  File "setup.py", line 108, in finalize_options
    __builtins__.__NUMPY_SETUP__ = False
AttributeError: 'dict' object has no attribute '__NUMPY_SETUP__'

My current workaround is this: https://github.com/RaRe-Technologies/gensim/blob/919b4154a5696a544b87f792992f25f5e4d59d3e/setup.py#L109

        try:
            __builtins__.__NUMPY_SETUP__ = False
        except AttributeError:
            print("Cannot set '__builtins__.__NUMPY_SETUP__ = False' This is not needed if numpy is already installed.")
mpenkov commented 2 years ago

What platform?

icanhasmath commented 2 years ago

Windows.

jaymegordo commented 2 years ago

+1 same thing on mac M1

icanhasmath commented 2 years ago

Noting this thread may be relevant: https://github.com/pyvista/pyacvd/pull/23#issue-1298467701 They dropped the __builtins__.__NUMPY_SETUP__ as outdated.

hangingman commented 6 months ago

This problem is fixed in gensim4, but is there any backport release ? I want to use gensim3 instead of gensim4. I'm happy if gensim 3.8.4 is released for backport , which will be resolved this __NUMPY_SETUP__ issue.

hangingman commented 6 months ago

I write this for those who missed reading it;

Gensim is being continuously tested under all supported Python versions. Support for Python 2.7 was dropped in gensim 4.0.0 – install gensim 3.8.3 if you must use Python 2.7.

gojomo commented 6 months ago

No further 3.8.x releases are expected, so you'd have to backport any fixes, or apply workarounds, on your own.

But also: improvements in a number of aspects of Gensim mean any such custom efforts might be better exerted porting code/models to use Gensim 4.x.

Further, any specific barriers you're facing, in upgrading to 4.x, that can be well-described could potentially get code/doc help in a future 4.x release – potentialy of public value to many users – while fixing things for a 4-year-old release on a Python (3.9) that is itself within 18mo of end-of-life may only have idiosyncratic private value to you.

hangingman commented 6 months ago

@gojomo Thank you for your explanation. Finally, I've used Python 3.8 + gensim3, then the problem is resolved.

In the first place why I'm using gensim3, because I would like to avoid the error of #3127 (I think, the issue point is the Doc2Vec model trained by gensim3 can't be used by gensim4.) . Then, I've encountered this #3225 because of I'm using latest python and gensim.

Further, any specific barriers you're facing, in upgrading to 4.x, that can be well-described could potentially get code/doc help in a future 4.x release – potentialy of public value to many users

In this point of view, I expect you to described how to resolve a issue , such a #3127. I speculate there is only one way (?). This is to say; training model by gensim4.

gojomo commented 6 months ago

@hangingman - Thanks, could you add a comment on #3127 describing the way you're seeing that problem? (Specifically: whether you're hitting the first variant originally reported – the model loads but then errors on subsequent use – or a failure-on-load, perhaps with exact same stack as others have shown? If you know the exact version(s) in which your model was created or successfuly loaded/used, those would be good to know, too.)