Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

ImportError: cannot import name contrib #37

Closed
tangzhenyu opened this issue Mar 14, 2017 · 12 comments
Closed

ImportError: cannot import name contrib #37

tangzhenyu opened this issue Mar 14, 2017 · 12 comments

Comments

@tangzhenyu
Copy link

Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/lib/python2.7/unittest/main.py", line 12, in
main(module=None)
File "/usr/lib/python2.7/unittest/main.py", line 94, in init
self.parseArgs(argv)
File "/usr/lib/python2.7/unittest/main.py", line 149, in parseArgs
self.createTests()
File "/usr/lib/python2.7/unittest/main.py", line 158, in createTests
self.module)
File "/usr/lib/python2.7/unittest/loader.py", line 130, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/usr/lib/python2.7/unittest/loader.py", line 91, in loadTestsFromName
module = import('.'.join(parts_copy))
File "seq2seq/init.py", line 24, in
from seq2seq import contrib
ImportError: cannot import name contrib
When I run"python -m unittest seq2seq.test.pipeline_test",I got this error.Could someone tell me how to solve this problem?

@tangzhenyu
Copy link
Author

Is this framework not support the version of tensorflow0.12.1?

@dennybritz
Copy link
Contributor

Yes, you need Tensorflow 1.0.

@tangzhenyu
Copy link
Author

alright,thanks

@sheerun
Copy link

sheerun commented Jul 4, 2017

I get the same error for tensorflow 1.2.1

@shawnnylxx
Copy link

shawnnylxx commented Jul 9, 2017

same error in tensorflow 1.2.1
it is OK when downgrade to tensorflow 1.0.1

@David-Levinthal
Copy link

broken in R1.3rc0

@David-Levinthal
Copy link

I believe this can be fixed by modifying seq2seq/seq2seq/contrib/seq2seq/helper.py per the instructions in:
https://github.com/google/seq2seq/pull/254/files

#from tensorflow.contrib.distributions.python.ops import bernoulli
#from tensorflow.contrib.distributions.python.ops import categorical
try:
from tensorflow.python.ops.distributions import bernoulli
from tensorflow.python.ops.distributions import categorical
except:
from tensorflow.contrib.distributions.python.ops import bernoulli
from tensorflow.contrib.distributions.python.ops import categorical
seems to work for me now with 1.3 rc0 and R1.2

@wandabwa2004
Copy link

@David-Levinthal is right. Just replace these lines in seq2seq/helper.py:

from tensorflow.contrib.distributions.python.ops import bernoulli
from tensorflow.contrib.distributions.python.ops import categorical

with these:

from tensorflow.python.ops.distributions import bernoulli
from tensorflow.python.ops.distributions import categorical

I'm running tensorflow 1.2

@jhancock1975
Copy link

I just ran into the same thing using tensorflow 1.3.0. Should I create a pull request, or has someone already created one?

@chenchiwei
Copy link

I got the same problem in tensorflow 1.4.1

@NajeebTyson
Copy link

same problem with tensorflow 1.5.0

@enockipp
Copy link

same problem with tf 1.5.0

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

No branches or pull requests

10 participants