spyder-kernels
spyder-kernels copied to clipboard
Automatically executing code at console startup seems broken
Problem Description
In the settings under the IPython tag there is the section "Start" where you can enter code that should be executed automatically when starting a new console.
Apparently the code added there is not properly executed when starting a new console, it seems like only parts of it are executed with a bit of randomness involved:
What steps reproduce the problem?
Add different imports to the Ipython start field in the settings, then start new console. These are my results:
-
import sys, import os
-> os imported, sys not imported. -
import sys, import os, import shutil
->os and shutil imported, sys not imported -
import os, import shutil, import sys
-> Only os imported, sys and shutil not imported. -
import random, import numpy, import sys, import os, import shutil
-> everything but sys imported -
import pandas as pd,pd.set_option('display.max_columns',25)
-> pandas imported, setting not set (still at default value 0).
Generally it seems that mostly sys
is not imported if it's there while other modules rarely have an issue.
My main issue is with pandas being imported but the following set_option()
-call not being executed.
What is the expected output? What do you see instead?
Everything in the autostart field should be imported and executed.
Versions
- Spyder version: 3.3.6
- Python version: 3.7.3 64-bit
- Qt version: 5.9.6
- PyQt version: 5.9.2
- Operating System name/version: Windows 10
Dependencies
IPython >=4.0 : 7.6.1 (OK)
cython >=0.21 : 0.29.12 (OK)
jedi >=0.9.0 : 0.13.3 (OK)
matplotlib >=2.0.0: 3.1.0 (OK)
nbconvert >=4.0 : 5.5.0 (OK)
numpy >=1.7 : 1.16.4 (OK)
pandas >=0.13.1 : 0.24.2 (OK)
pycodestyle >=2.3 : 2.5.0 (OK)
pyflakes >=0.6.0 : 2.1.1 (OK)
pygments >=2.0 : 2.4.2 (OK)
pylint >=0.25 : 2.3.1 (OK)
qtconsole >=4.2.0 : 4.5.1 (OK)
rope >=0.9.4 : 0.14.0 (OK)
sphinx >=0.6.6 : 2.1.2 (OK)
sympy >=0.7.3 : 1.4 (OK)
@steff456, please take a look at this one.
I could reproduce this issue, but the problem is coming from spyder-kernels instead of spyder. I'm transfering this issue there.
@Khris777 I found the error, but please remember that in order to enter code that should be executed automatically when starting a new console it needs to be separated by ;
not ,
@steff456 Thank you for the advice.
I am using the german localization of Spyder and the explanation in the options tells me I have to use commas.
EDIT: When adding
import pandas as pd; pd.set_option('display.max_columns',25); pd.set_option('display.unicode.east_asian_width',True); pd.set_option('display.max_colwidth',30); pd.set_option('precision',5)
to autostart using semicolons, it does not work, pandas is not imported.