简体   繁体   中英

How to import the tensorflow go packages when using go modules in a project?

So I have a project and I am using go modules. However I need to use the tensorflow package, but it seems tensorflow is not yet supporting go modules. Is there a way to import those two dependencies despite the lack of module definitions?

The following 2 imports seem to cause the problems:

tf "github.com/tensorflow/tensorflow/tensorflow/go"
"github.com/tensorflow/tensorflow/tensorflow/go/op"  

When I try to download the packages I get the following output:

$ go get -u "github.com/tensorflow/tensorflow/tensorflow/go/op"
go: finding github.com/tensorflow/tensorflow/tensorflow/go/op latest
go: finding github.com/tensorflow/tensorflow/tensorflow/go latest
go: finding github.com/tensorflow/tensorflow/tensorflow latest
go get github.com/tensorflow/tensorflow/tensorflow/go/op: no matching versions for query "latest"

However in my test project which still used the old way of importing packages everything worked just fine.

Edit:

After some testing I realized that the issue only happens with the go packages of tensorflow. All others, even if not originally written with go modules, work just fine.

I corrected the imports in the original question, as well as the title.

So for now I use a dirty workaround to get around this issue. I just ripped out go modules from my project entirely by removing go.mod and go.sum files and setting GO111MODULE=off .

It is not the best solution, hence I do not accept the answer, but for now I can continue working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM