The code I am trying to run is
import graph_nets as gn
and the compiler returns
ImportError: cannot import name 'Sonnet' from 'graphs'
which traces back to a line in the sonnet package that says from graphs import Sonnet, D3Graph, MatplotGraph
(I have seen many similar errors on forums and the common solution is
pip uninstall sonnet
pip install dm-sonnet
but this doesn't work for me as pip install dm-sonnet
is responded with requirement already satisfied
and uninstalling sonnet makes the compiler return
module 'sonnet' has no attribute '__version__'
for the same line of code I am trying to run) The there other possible solutions?
CodePudding user response:
AFAIU the correct package you need is dm-sonnet
. But you have already installed sonnet
. Now you need to reinstall dm-sonnet
to remove remnants of sonnet
and install dm-sonnet
afresh.
pip uninstall -y dm-sonnet
pip install dm-sonnet
Or simply
pip install --ignore-installed dm-sonnet
To use dm-sonnet
you need tensorflow
. dm-sonnet
doesn't automatically install tensorflow
as a dependency so you need to install it yourself:
pip install tensorflow