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.

Spyder crashes upon typing `net(` in editor

See original GitHub issue

Description of your problem

I execute the code below. Then try to type net( and Spyder crashes.

What steps will reproduce the problem? Execute this code:

import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import numpy as np



class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        # 1 input image channel, 6 output channels, 5x5 square convolution
        # kernel
        self.conv1 = nn.Conv2d(1, 6, 5) # Takes 4D input: nSamples + nChannels x Height x Width
        self.conv2 = nn.Conv2d(6, 16, 5)
        # an affine operation: y = Wx + b
        self.fc1 = nn.Linear(16 * 5 * 5, 120)
        self.fc2 = nn.Linear(120, 84)
        self.fc3 = nn.Linear(84, 10)

    def forward(self, x):
        # Max pooling over a (2, 2) window
        x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2))
        # If the size is a square you can only specify a single number
        x = F.max_pool2d(F.relu(self.conv2(x)), 2)
        x = x.view(-1, self.num_flat_features(x))
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        x = self.fc3(x)
        return x

    def num_flat_features(self, x):
        size = x.size()[1:]  # all dimensions except the batch dimension
        num_features = 1
        for s in size:
            num_features *= s
        return num_features

net = Net()
print(net)

*Code comes from PyTorch Tutorial webpage (http://pytorch.org/tutorials/beginner/blitz/neural_networks_tutorial.html)

I saved this file as YSTest.py

What is the expected output? What do you see instead? Expected output is word net() appearing in editor. The net object is instance of Net class, so there should be no reason why I am unable to get this to work properly.

Please provide any additional information below Often, but not always (and this is hard to replicate, but very annoying) Spyder will crash if I type net( into the YSTest.py file BEFORE executing a single line of code. Curiously, this problem manifests only if net( is typed in the YSTest.py file that has the code above. Typing net( in a new Python file adjacent to the YSTest.py file results in no error (with or without packages loaded). In fact, if I execute the code above and type net( in a new python file in Spyder, there is no error. Similarly, there is no error with typing net( in the IPython kernel (it even brings up the expected in-line documentation support instantly!)

This led me to believe the YSTest.py file is corrupted, so I made new such file in a clean directory by manually typing all commands above in. Problem persists. Running spyder --reset and restarting my computer did not resolve the issue either…

Versions and main components

  • Spyder Version: 3.2.4
  • Python Version: 2.7
  • Qt Version: 5.6.2
  • PyQt Version: 5.6
  • Operating system: Ubuntu 14.04

Dependencies

Please go to the menu entry Help > Optional Dependencies (or Help > Dependencies), press the button Copy to clipboard and paste the contents below:

IPython >=4.0;<6.0: 5.4.1 (OK) cython >=0.21 : 0.26.1 (OK) jedi >=0.9.0 : 0.10.2 (OK) nbconvert >=4.0 : 5.3.1 (OK) numpy >=1.7 : 1.13.3 (OK) pandas >=0.13.1 : 0.20.3 (OK) psutil >=0.3 : 5.4.0 (OK) pycodestyle >=2.3 : 2.3.1 (OK) pyflakes >=0.5.0 : 1.6.0 (OK) pygments >=2.0 : 2.2.0 (OK) pylint >=0.25 : 1.7.4 (OK) qtconsole >=4.2.0 : 4.3.1 (OK) rope >=0.9.4 : 0.10.5 (OK) sphinx >=0.6.6 : 1.6.3 (OK) sympy >=0.7.3 : 1.1.1 (OK)

Additional info: PyTorch version: 0.3.0.post4 *Installed PyTorch via Anaconda for Python 2.7 as per official install instructions (http://pytorch.org/): conda install pytorch torchvision -c pytorch for PyTorch without CUDA

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:21 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
ysumath1commented, Dec 28, 2017

enable spyder debug mode and then start it from that command line, you can then watch exactly what’s going on under the hood when the behavior happens, which would probably be of some help in fixing it.

Tried this today. I execute the code above, no errors; terminal shows bunch of outputs that show everything is okay (not posting here, bc. very long; both jedi and rope initialize as expected without errors). Program ends, and I click to new empty line at end of program; Jedi is initialized without problems (first line in terminal output below). I then type net( and program crashes. Below, find rest of terminal output. Seems like problem is with rope or torch.nn.modules.module.Module modul

Initialized jedi
info request
info request from rope finished: "{'calltip': u'__call__(*input, **kwargs)', 'note': u'Present in torch.nn.modules.module.Module modul" in 0.2 sec
Segmentation fault (core dumped)

Let me know if there are others things you’d like me to explore.

0reactions
csabellacommented, Dec 31, 2017

I type net( (after re-enabling the balloon tips option in editor) and that works (I get net() and some balloon tips). To make sure it’s not a fluke, I create a new line and type 'net(` and Spyder crashes…

@ysumath1 I can now recreate it by typing net( twice! Thank you for your diligence in helping us work on this. Next step for me is to now find the root cause. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

When a letter is typed while coding, the spyder ide freezes for ...
I have an issue with typing the letter "i" in the code editor. When I type that letter, Spyder freezes for a moment...
Read more >
spyderlib - Google Code
ID Status Summary 2225 New Memory error Type‑Defect Priority‑Medium 2223 New file "" Type‑Defect Priority‑Medium 2221 New M Type‑Defect Priority‑Medium
Read more >
Bug #1968479 “[22.04] Spyder (Python3) doesn't start”
Spyder doesn't start in Ubuntu 22.04 beta (latest updates as on 2022/04/10) anymore: (Clean install, default theme). ``` $ spyder
Read more >
Spyder keeps crashing. Need an alernative IDE for learning ...
My proff recommended spyder to use as an IDE but I'm finding it really frustrating to use. It keeps on crashing again and...
Read more >
slow code completion in editor (all of the sudden)
I have been using Spyder regularly for over a year on Windows with 64 bit ... Spyder freezes (not responding) for several seconds...
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