Alfred Wallace
Alfred Wallace

Reputation: 1984

No output in IPython Console in Spyder (Anaconda)

When I run the following code, I see zero output in the Console. In another piece of code where I have a logger, the logger also stays blank. It looks like Spyder (Anaconda) is not executing.

import alpaca_trade_api as tradeapi
import nest_asyncio
nest_asyncio.apply()

from apikeys import API_KEY, SECRET_KEY
base_url = 'https://paper-api.alpaca.markets'
api_key_id = API_KEY
api_secret = SECRET_KEY

conn = tradeapi.StreamConn(
    key_id=api_key_id,
    secret_key=api_secret, 
    base_url=base_url, 
    data_stream='polygon')

def run():
    @conn.on(r'^A$')
    async def on_second_bar(conn, channel, data):
        print(data.close)
    conn.run(['A.AMZN'])
    
run()
In [1]: runfile('C:/Code/untitled1.py', wdir='C:/Code')

(empty lines)

However, when I click Remove all variables, then the script executes as expected.

Removing all variables... 
3022.24
3023.09

Is the script programmatically incorrect or am I missing something with settings?

Upvotes: 0

Views: 2242

Answers (1)

Alfred Wallace
Alfred Wallace

Reputation: 1984

Turns out this is a documented issue in Spyder for multiprocessing, per an official Spyder maintainer: No multiprocessing print outputs (Spyder)

Workaround is to use an external console terminal:

Tools > Preferences > Run > Console > Execute in an external system terminal

Upvotes: 1

Related Questions