question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: cannot import name 'weakref'

See original GitHub issue

any comment?

➜  baselines git:(master) python baselines/pposgd/run_atari.py
Traceback (most recent call last):
  File "baselines/pposgd/run_atari.py", line 54, in <module>
    main()
  File "baselines/pposgd/run_atari.py", line 51, in main
    train('PongNoFrameskip-v4', num_timesteps=40e6, seed=0, num_cpu=8)
  File "baselines/pposgd/run_atari.py", line 18, in train
    from baselines.pposgd import pposgd_simple, cnn_policy
  File "/Users/Tiger/projects/baselines/baselines/pposgd/pposgd_simple.py", line 3, in <module>
    import baselines.common.tf_util as U
  File "/Users/Tiger/projects/baselines/baselines/common/tf_util.py", line 2, in <module>
    import tensorflow as tf  # pylint: ignore-module
  File "/Users/Tiger/anaconda/lib/python3.5/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/Users/Tiger/anaconda/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 63, in <module>
    from tensorflow.python.framework.framework_lib import *
  File "/Users/Tiger/anaconda/lib/python3.5/site-packages/tensorflow/python/framework/framework_lib.py", line 100, in <module>
    from tensorflow.python.framework.subscribe import subscribe
  File "/Users/Tiger/anaconda/lib/python3.5/site-packages/tensorflow/python/framework/subscribe.py", line 26, in <module>
    from tensorflow.python.ops import variables
  File "/Users/Tiger/anaconda/lib/python3.5/site-packages/tensorflow/python/ops/variables.py", line 26, in <module>
    from tensorflow.python.ops import control_flow_ops
  File "/Users/Tiger/anaconda/lib/python3.5/site-packages/tensorflow/python/ops/control_flow_ops.py", line 70, in <module>
    from tensorflow.python.ops import tensor_array_ops
  File "/Users/Tiger/anaconda/lib/python3.5/site-packages/tensorflow/python/ops/tensor_array_ops.py", line 33, in <module>
    from tensorflow.python.util import tf_should_use
  File "/Users/Tiger/anaconda/lib/python3.5/site-packages/tensorflow/python/util/tf_should_use.py", line 28, in <module>
    from backports import weakref  # pylint: disable=g-bad-import-order
ImportError: cannot import name 'weakref'

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

10reactions
pnlawlorcommented, Jan 25, 2018

I was having the same issue. The following worked for me:

In path/to/python/env/Lib/site-packages/tensorflow/python/util/tf_should_use.py Change line 28: from backports import weakref # pylint: disable=g-bad-import-order to import weakref

0reactions
iamhabbeboycommented, Nov 30, 2018

Locate the path here for mac user /usr/local/lib/python2.7/site-packages/tensorflow/python/util/tf_should_use.py then continue with @pnlawlor solution

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImportError: cannot import name '_remove_dead_weakref'
Appear when I try to run server in pycharm. #django project. bash -cl "/home/encuentrum/venv-encuentrum3/bin/python /usr/share/pycharm/ ...
Read more >
ImportError: cannot import name _remove_dead_weakref
I recently ran into this issue when I was using Pycharm 2017.3.2 on Ubuntu 16.10. My setup was: I installed Python 3.6 from...
Read more >
Cannot Import Name _Remove_dead_weakref in Python
The ImportError is an exception that occurs while importing some modules. This can be because the module does not exist or due to...
Read more >
ImportError: cannot import name _remove_dead_weakref
After upgrading from debian stretch to buster, celery stopped to work with the error message above. In the indico venv pip also prints...
Read more >
ImportError: cannot import name _remove_dead_weakref
File “/usr/lib/python2.7/weakref.py”, line 14, in ** ** from _weakref import (** ** ImportError: cannot import name _remove_dead_weakref**.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found