Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import dimod fails on Python 3.7.10 with dimod 0.10.0 #901

Closed
j-i-k-o opened this issue Jul 16, 2021 · 5 comments
Closed

import dimod fails on Python 3.7.10 with dimod 0.10.0 #901

j-i-k-o opened this issue Jul 16, 2021 · 5 comments
Labels

Comments

@j-i-k-o
Copy link

j-i-k-o commented Jul 16, 2021

Description
import dimod on Python 3.7.10 causes a TypeError exception.

❯ python           
Python 3.7.10 (default, Jul 16 2021, 19:59:05) 
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dimod
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/__init__.py", line 18, in <module>
    from dimod.bqm import *
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/bqm/__init__.py", line 15, in <module>
    from dimod.bqm.adjvectorbqm import AdjVectorBQM
  File "dimod/bqm/adjvectorbqm.pyx", line 38, in init dimod.bqm.adjvectorbqm
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/core/__init__.py", line 15, in <module>
    from dimod.core.composite import Composite, ComposedSampler
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/core/composite.py", line 67, in <module>
    from dimod.core.sampler import Sampler
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/core/sampler.py", line 110, in <module>
    from dimod.binary_quadratic_model import BinaryQuadraticModel
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/binary_quadratic_model.py", line 17, in <module>
    from dimod.binary.binary_quadratic_model import BinaryQuadraticModel, BQM
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/binary/__init__.py", line 15, in <module>
    from dimod.binary.binary_quadratic_model import *
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/binary/binary_quadratic_model.py", line 30, in <module>
    from numpy.typing import ArrayLike, DTypeLike
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/numpy/typing/__init__.py", line 315, in <module>
    from ._shape import _Shape, _ShapeLike
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/numpy/typing/_shape.py", line 15, in <module>
    _ShapeLike = Union[SupportsIndex, Sequence[SupportsIndex]]
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/typing.py", line 254, in inner
    return func(*args, **kwds)
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/typing.py", line 634, in __getitem__
    params = tuple(_type_check(p, msg) for p in params)
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/typing.py", line 634, in <genexpr>
    params = tuple(_type_check(p, msg) for p in params)
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/typing.py", line 142, in _type_check
    raise TypeError(f"{msg} Got {arg!r:.100}.")
TypeError: Parameters to generic types must be types. Got NotImplemented.
>>> 

Steps To Reproduce

  1. install python 3.7.10 on Linux
  2. install dimod (with wheel package dimod-0.10.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl)
  3. import dimod

Expected Behavior

Python 3.7.10 (default, Jul 16 2021, 19:59:05) 
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dimod
>>>

Environment

  • OS: Arch Linux (with Linux kernel 5.12.10-arch1-1)
  • Python version: 3.7.10
@j-i-k-o j-i-k-o changed the title import dimod fails on Python 3.7 with dimod 0.10.0 import dimod fails on Python 3.7.10 with dimod 0.10.0 Jul 16, 2021
@hhtong
Copy link
Contributor

hhtong commented Jul 16, 2021

Hi @j-i-k-o, thanks for bringing this up.

What version of numpy are you using? If it’s 1.21, I believe the error is coming directly from numpy: see numpy/numpy#19310. This problem should be fixed by 1.21.1 (see numpy/numpy#19311).

As a temporary fix, you could try downgrading your numpy (should work with 1.20), or try a python >= 3.8.

Hope this helps!

@j-i-k-o
Copy link
Author

j-i-k-o commented Jul 16, 2021

HI @hhtong, thanks for the comment!

❯ python -m pip show numpy
Name: numpy
Version: 1.21.0
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email: None
License: BSD
Location: /home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages
Requires: 
Required-by: dimod

Yes, The version of numpy is 1.21.0.
I'm going to wait until numpy is uploaded to 1.21.1.
Many thanks.

@j-i-k-o
Copy link
Author

j-i-k-o commented Jul 19, 2021

I upgraded numpy and dimod to 1.21.1 and 0.10.2, respectively, which still has a similar error.

❯ python --version
Python 3.7.10

~
❯ python -m pip show dimod            
Name: dimod
Version: 0.10.2
Summary: A shared API for binary quadratic model samplers.
Home-page: https://github.com/dwavesystems/dimod
Author: D-Wave Systems Inc.
Author-email: tools@dwavesys.com
License: Apache 2.0
Location: /home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages
Requires: numpy
Required-by: 

~
❯ python -m pip show numpy
Name: numpy
Version: 1.21.1
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email: None
License: BSD
Location: /home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages
Requires: 
Required-by: dimod

~
❯ python                  
Python 3.7.10 (default, Jul 16 2021, 19:59:05) 
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dimod
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/__init__.py", line 18, in <module>
    from dimod.bqm import *
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/bqm/__init__.py", line 15, in <module>
    from dimod.bqm.adjvectorbqm import AdjVectorBQM
  File "dimod/bqm/adjvectorbqm.pyx", line 38, in init dimod.bqm.adjvectorbqm
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/core/__init__.py", line 15, in <module>
    from dimod.core.composite import Composite, ComposedSampler
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/core/composite.py", line 67, in <module>
    from dimod.core.sampler import Sampler
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/core/sampler.py", line 110, in <module>
    from dimod.binary_quadratic_model import BinaryQuadraticModel
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/binary_quadratic_model.py", line 17, in <module>
    from dimod.binary.binary_quadratic_model import BinaryQuadraticModel, BQM
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/binary/__init__.py", line 15, in <module>
    from dimod.binary.binary_quadratic_model import *
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/dimod/binary/binary_quadratic_model.py", line 30, in <module>
    from numpy.typing import ArrayLike, DTypeLike
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/numpy/typing/__init__.py", line 316, in <module>
    from ._dtype_like import (
  File "/home/jiko/.pyenv/versions/3.7.10/lib/python3.7/site-packages/numpy/typing/_dtype_like.py", line 95, in <module>
    class _SupportsDType(Generic[_DType_co]):
NameError: name '_DType_co' is not defined
>>> 

I suppose the current quick solution is to install typing_extensions package since the problem basically comes from typing_extensions in numpy (numpy/numpy#19310)

❯ python -m pip install typing_extensions
Collecting typing_extensions
  Using cached typing_extensions-3.10.0.0-py3-none-any.whl (26 kB)
Installing collected packages: typing-extensions
Successfully installed typing-extensions-3.10.0.0
WARNING: You are using pip version 20.1.1; however, version 21.1.3 is available.
You should consider upgrading via the '/home/jiko/.pyenv/versions/3.7.10/bin/python -m pip install --upgrade pip' command.
❯ python                                 
Python 3.7.10 (default, Jul 16 2021, 19:59:05) 
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dimod
>>> 

@hhtong
Copy link
Contributor

hhtong commented Jul 19, 2021

I've opened an issue on numpy here: numpy/numpy#19521

@arcondello
Copy link
Member

Closing since NumPy 1.21.2+ is now deployed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants