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.

Pytorch method 'detach' already has a docstring

See original GitHub issue

Problem Description

Hello, whenever the pytorch/torch package is imported and I try to import again (say when I just run the whole script or another script that uses import torch) I get the error output: “method ‘detach’ already has a docstring”. I’m not the only one experiencing this issue (see https://discuss.pytorch.org/t/method-detach-already-has-a-docstring/74676/12) and it seems to be a Spyder specific issue.

What steps reproduce the problem?

  1. Import torch in Spyder
  2. rerun import torch (rerun a script)

What is the expected output? What do you see instead?

The script runs normally the first time, but upon rerunning, it errors on import.

Paste Traceback/Error Below (if applicable)



  File "/home/alex/Documents/QML_Research/Variational_Learning_Implementations/Python_Autoregressive/Test_E_loc", line 9, in <module>
    import torch

  File "/home/alex/anaconda3/envs/Pytorch/lib/python3.6/site-packages/torch/__init__.py", line 188, in <module>
    from .tensor import Tensor

  File "/home/alex/anaconda3/envs/Pytorch/lib/python3.6/site-packages/torch/tensor.py", line 41, in <module>
    class Tensor(torch._C._TensorBase):

  File "/home/alex/anaconda3/envs/Pytorch/lib/python3.6/site-packages/torch/tensor.py", line 282, in Tensor
    """)

RuntimeError: method 'detach' already has a docstring

Versions

  • Spyder version: 3.2.8
  • Python version: 3.6
  • Qt version: 5.9.6
  • PyQt version: 5.9.2
  • Operating System name/version: Ubuntu, 18.04

Dependencies

Thanks for the help and hard work, Spyder is a great IDE

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ghostcommented, May 13, 2020

Yes, You are right. Installing the newest version of Spyder worked for me.

0reactions
HapaxHypatiacommented, Mar 20, 2021

I have a fresh install of the latest version of Spyder (4.2.4) but still get this error. In my case, torch is being called by another library (allosaurus). It will run with no problems the first time, but I have to restart the kernel before it will work again

`Traceback (most recent call last):

File “C:\projects\allosaurus test.py”, line 8, in <module> from allosaurus.app import read_recognizer

File “C:\Program Files\Spyder\pkgs\allosaurus\app.py”, line 1, in <module> from allosaurus.am.utils import *

File “C:\Program Files\Spyder\pkgs\allosaurus\am\utils.py”, line 1, in <module> import torch

File “C:\Program Files\Spyder\pkgs\torch_init_.py”, line 447, in <module> from .tensor import Tensor

File “C:\Program Files\Spyder\pkgs\torch\tensor.py”, line 13, in <module> from torch.overrides import (

File “C:\Program Files\Spyder\pkgs\torch\overrides.py”, line 1229, in <module> “”"

RuntimeError: function ‘_has_torch_function’ already has a docstring`

Read more comments on GitHub >

github_iconTop Results From Across the Web

Method 'detach' already has a docstring - PyTorch Forums
Hi When i try to save my model using torch.save i get this error.
Read more >
method 'detach' already has a docstring" Can someone help?
I tried reinstalling, upgrading, downgrading nothing seems to help. Programs that don't import torch run fine.
Read more >
Why do we call .detach() before calling .numpy() on a Pytorch ...
This other Tensor can then be converted to a numpy array. In other words, the detach method means "I don't want gradients," and...
Read more >
Issue 7954: detach method has no docstring - Python tracker
The detach() method has no docstring, so it's impossible to find out about it with pydoc or help(). It would be great if...
Read more >
Source code for transformers.file_utils - Hugging Face
Note that if you have a local folder named `datasets` or a local python file named ... docstyle-ignore PYTORCH_IMPORT_ERROR = """ {0} requires...
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