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.

Code does not execute in Spyder, instead a new Console is created.

See original GitHub issue

Issue Report Checklist

  • [ X] Searched the issues page for similar reports
  • [ X] Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
  • [ X] Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)
  • Could not reproduce inside jupyter qtconsole (if console-related)
  • [ X] Tried basic troubleshooting (if a bug/error)
    • [X ] Restarted Spyder
    • [X ] Reset preferences with spyder --reset
    • [ X] Reinstalled the latest version of Anaconda
    • [ X] Tried the other applicable steps from the Troubleshooting Guide
  • [ X] Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

When executing code, Spyder just opens a new console instead of executing the code. Other code works, just this snippet does not.

What steps reproduce the problem?

  1. Run the following piece of code:
from datetime import datetime

def previous_quarter(month, year):
    quarters = {
            1: [1, 2, 3],
            2: [4, 5, 6],
            3: [7, 8, 9],
            4: [10, 11, 12]
            }
    for q in quarters:
        if month in quarters[q]:
            print(q)
            exit(1)

    return month, year

d = datetime.now().day
m = datetime.now().month
y = datetime.now().year

pq = previous_quarter(m, y)
  1. In above code, the problem is reproduced even if the last 4 statements are run separately (using F9), after the previous statements are run. If everything is executed together, the issue seems to persist.

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

Expected output is either an error statement, or the printed numeric value of variable “q”, followed by a forced exit.

Paste Traceback/Error Below (if applicable)


PASTE TRACEBACK HERE

Versions

  • Spyder version: Spyder 3.2.8
  • Python version: Python 3.5.2 64bits
  • Qt version: Qt 5.9.3
  • PyQt version: PyQt5 5.9.2 on Linux
  • Operating System name/version: Linux [Linux raptorx 4.4.0-128-generic #154-Ubuntu SMP Fri May 25 14:15:18 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux] Distributor ID: Ubuntu Description: Ubuntu 16.04.4 LTS Release: 16.04 Codename: xenial

Dependencies

IPython >=4.0    :  6.2.1 (OK)
cython >=0.21    :  None (NOK)
jedi >=0.9.0     :  0.11.1 (OK)
nbconvert >=4.0  :  5.3.1 (OK)
numpy >=1.7      :  1.14.2 (OK)
pandas >=0.13.1  :  None (NOK)
psutil >=0.3     :  5.4.3 (OK)
pycodestyle >=2.3:  2.3.1 (OK)
pyflakes >=0.6.0 :  1.6.0 (OK)
pygments >=2.0   :  2.2.0 (OK)
pylint >=0.25    :  1.8.3 (OK)
qtconsole >=4.2.0:  4.3.1 (OK)
rope >=0.9.4     :  0.10.7 (OK)
sphinx >=0.6.6   :  1.7.2 (OK)
sympy >=0.7.3    :  None (NOK)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
bcolsencommented, Jun 24, 2018

I can reproduce this, but I don’t think that it’s a bug. That’s what exit(1) does, it closes the console. That’s why Spyder starts a new one.

I think in this case break is what you are looking for not exit(). https://docs.python.org/3/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops

0reactions
parichayacommented, Jun 25, 2018

Hi,

Sorry about that. Thank you for pointing it out!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spyder does not run my new code - Error Message ... - GitHub
Any part of my Script reproduce the issue, even just import some libraries. For Example: `import re from pydrive.auth import GoogleAuth
Read more >
A very basic setting issue about spyder and anaconda for python
You can specify the Spyder's Run Settings in Run -> Configure (F6). By default "Execute in current Python or IPython console" is selected...
Read more >
IPython Console — Spyder 3 documentation
Spyder can launch new IPython instances itself, through “Open an IPython console” under the Consoles menu, the IPython Console pane menu or its...
Read more >
Python console | PyCharm Documentation - JetBrains
Run several Python consoles · Click New Console to add a new Python console. · By default, each console has the name Python...
Read more >
Python Code Blocks and Debugging (Spyder 5 IDE) - YouTube
This video is an overview of the inbuilt Python programming language and will focus on structuring your code using code blocks.
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