spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.2k stars 1.59k forks source link

Defining a function #22161

Closed moosemoose19 closed 3 months ago

moosemoose19 commented 3 months ago

Description

What steps will reproduce the problem?

Cannot define a function. When I attempt to define a function and run it I receive the following error, SyntaxError: incomplete input.

Have tried reinstalling anaconda, spyder, etc. and making sure that they are up-to-date.

Used the following code:

def my_function():
    print("Hello from a function")

my_function()

Received the following in the console:

In [1]: def my_function():
  Cell In[1], line 1
    def my_function():
                      ^
SyntaxError: incomplete input

In [2]: print("Hello from a function")
Hello from a function

In [3]: 

I can, however, run the same code in a python console outside of spyder without issue.

Versions

Dependencies

# Mandatory:
atomicwrites >=1.2.0             :  1.4.0 (OK)
chardet >=2.0.0                  :  4.0.0 (OK)
cloudpickle >=0.5.0              :  2.2.1 (OK)
cookiecutter >=1.6.0             :  2.6.0 (OK)
diff_match_patch >=20181111      :  20200713 (OK)
intervaltree >=3.0.2             :  3.1.0 (OK)
IPython >=8.13.0,<9.0.0,!=8.17.1 :  8.20.0 (OK)
jedi >=0.17.2,<0.20.0            :  0.18.1 (OK)
jellyfish >=0.7                  :  1.0.1 (OK)
jsonschema >=3.2.0               :  4.19.2 (OK)
keyring >=17.0.0                 :  24.3.1 (OK)
nbconvert >=4.0                  :  7.10.0 (OK)
numpydoc >=0.6.0                 :  1.5.0 (OK)
paramiko >=2.4.0                 :  2.8.1 (OK)
parso >=0.7.0,<0.9.0             :  0.8.3 (OK)
pexpect >=4.4.0                  :  4.8.0 (OK)
pickleshare >=0.4                :  0.7.5 (OK)
psutil >=5.3                     :  5.9.0 (OK)
pygments >=2.0                   :  2.15.1 (OK)
pylint >=2.5.0,<3.1              :  2.16.2 (OK)
pylint_venv >=3.0.2              :  3.0.3 (OK)
pyls_spyder >=0.4.0              :  0.4.0 (OK)
pylsp >=1.10.0,<1.11.0           :  1.10.0 (OK)
pylsp_black >=2.0.0,<3.0.0       :  2.0.0 (OK)
qdarkstyle >=3.2.0,<3.3.0        :  3.2.3 (OK)
qstylizer >=0.2.2                :  0.2.2 (OK)
qtawesome >=1.2.1                :  1.2.2 (OK)
qtconsole >=5.5.1,<5.6.0         :  5.5.1 (OK)
qtpy >=2.1.0                     :  2.4.1 (OK)
rtree >=0.9.7                    :  1.0.1 (OK)
setuptools >=49.6.0              :  69.5.1 (OK)
sphinx >=0.6.6                   :  5.0.2 (OK)
spyder_kernels >=2.5.0,<2.6.0    :  2.5.0 (OK)
textdistance >=4.2.0             :  4.2.1 (OK)
three_merge >=0.1.1              :  0.1.1 (OK)
watchdog >=0.10.3                :  4.0.1 (OK)
zmq >=22.1.0                     :  25.1.2 (OK)

# Optional:
cython >=0.21                    :  None (NOK)
matplotlib >=3.0.0               :  3.8.4 (OK)
numpy >=1.7                      :  1.26.4 (OK)
pandas >=1.1.1                   :  None (NOK)
scipy >=0.17.0                   :  1.13.1 (OK)
sympy >=0.7.3                    :  None (NOK)

Environment

Environment ``` # packages in environment at C:\ProgramData\anaconda3\envs\spyder-images: # # Name Version Build Channel alabaster 0.7.12 pyhd3eb1b0_0 aom 3.6.0 hd77b12b_0 arrow 1.2.3 py311haa95532_1 astroid 2.14.2 py311haa95532_0 asttokens 2.0.5 pyhd3eb1b0_0 atomicwrites 1.4.0 py_0 attrs 23.1.0 py311haa95532_0 autopep8 2.0.4 pyhd3eb1b0_0 babel 2.11.0 py311haa95532_0 bcrypt 3.2.0 py311h2bbff1b_1 beautifulsoup4 4.12.3 py311haa95532_0 binaryornot 0.4.4 pyhd3eb1b0_1 black 24.4.2 py311haa95532_0 blas 1.0 mkl bleach 4.1.0 pyhd3eb1b0_0 blosc 1.21.3 h6c2663c_0 brotli 1.0.9 h2bbff1b_8 brotli-bin 1.0.9 h2bbff1b_8 brotli-python 1.0.9 py311hd77b12b_8 bzip2 1.0.8 h2bbff1b_6 ca-certificates 2024.3.11 haa95532_0 certifi 2024.6.2 py311haa95532_0 cffi 1.16.0 py311h2bbff1b_1 cfitsio 3.470 h2bbff1b_7 chardet 4.0.0 py311haa95532_1003 charls 2.2.0 h6c2663c_0 charset-normalizer 2.0.4 pyhd3eb1b0_0 click 8.1.7 py311haa95532_0 cloudpickle 2.2.1 py311haa95532_0 colorama 0.4.6 py311haa95532_0 comm 0.2.1 py311haa95532_0 contourpy 1.2.0 py311h59b6b97_0 cookiecutter 2.6.0 py311haa95532_0 cryptography 42.0.5 py311h89fc84f_1 cycler 0.11.0 pyhd3eb1b0_0 dav1d 1.2.1 h2bbff1b_0 debugpy 1.6.7 py311hd77b12b_0 decorator 5.1.1 pyhd3eb1b0_0 defusedxml 0.7.1 pyhd3eb1b0_0 diff-match-patch 20200713 pyhd3eb1b0_0 dill 0.3.8 py311haa95532_0 docstring-to-markdown 0.11 py311haa95532_0 docutils 0.18.1 py311haa95532_3 eigen 3.4.0 h59b6b97_0 executing 0.8.3 pyhd3eb1b0_0 ffmpeg 4.2.2 he774522_0 flake8 7.0.0 py311haa95532_0 fonttools 4.51.0 py311h2bbff1b_0 freetype 2.12.1 ha860e81_0 giflib 5.2.1 h8cc25b3_3 glib 2.78.4 hd77b12b_0 glib-tools 2.78.4 hd77b12b_0 gst-plugins-base 1.18.5 h9e645db_0 gstreamer 1.18.5 hd78058f_0 hdf5 1.12.1 h51c971a_3 icc_rt 2022.1.0 h6049295_2 icu 58.2 ha925a31_3 idna 3.7 py311haa95532_0 imagecodecs 2023.1.23 py311he6ff3c7_0 imageio 2.33.1 py311haa95532_0 imagesize 1.4.1 py311haa95532_0 importlib-metadata 7.0.1 py311haa95532_0 importlib_metadata 7.0.1 hd3eb1b0_0 inflection 0.5.1 py311haa95532_0 intel-openmp 2023.1.0 h59b6b97_46320 intervaltree 3.1.0 pyhd3eb1b0_0 ipykernel 6.28.0 py311haa95532_0 ipython 8.20.0 py311haa95532_0 ipython_genutils 0.2.0 pyhd3eb1b0_1 isort 5.9.3 pyhd3eb1b0_0 jaraco.classes 3.2.1 pyhd3eb1b0_0 jedi 0.18.1 py311haa95532_1 jellyfish 1.0.1 py311h36a85e1_0 jinja2 3.1.4 py311haa95532_0 jpeg 9e h2bbff1b_1 jsonschema 4.19.2 py311haa95532_0 jsonschema-specifications 2023.7.1 py311haa95532_0 jupyter_client 8.6.0 py311haa95532_0 jupyter_core 5.5.0 py311haa95532_0 jupyterlab_pygments 0.2.2 py311haa95532_0 keyring 24.3.1 py311haa95532_0 kiwisolver 1.4.4 py311hd77b12b_0 krb5 1.20.1 h5b6d351_0 lazy-object-proxy 1.10.0 py311h2bbff1b_0 lazy_loader 0.3 py311haa95532_0 lcms2 2.12 h83e58a3_0 lerc 3.0 hd77b12b_0 libaec 1.0.4 h33f27b4_1 libavif 0.11.1 h2bbff1b_0 libbrotlicommon 1.0.9 h2bbff1b_8 libbrotlidec 1.0.9 h2bbff1b_8 libbrotlienc 1.0.9 h2bbff1b_8 libclang 14.0.6 default_hb5a9fac_1 libclang13 14.0.6 default_h8e68704_1 libdeflate 1.17 h2bbff1b_1 libffi 3.4.4 hd77b12b_1 libglib 2.78.4 ha17d25a_0 libiconv 1.16 h2bbff1b_3 libogg 1.3.5 h2bbff1b_1 libpng 1.6.39 h8cc25b3_0 libpq 12.17 h906ac69_0 libprotobuf 3.20.3 h23ce68f_0 libsodium 1.0.18 h62dcd97_0 libspatialindex 1.9.3 h6c2663c_0 libtiff 4.5.1 hd77b12b_0 libvorbis 1.3.7 he774522_0 libwebp 1.3.2 hbc33d0d_0 libwebp-base 1.3.2 h2bbff1b_0 libxml2 2.10.4 h0ad7f3c_2 libxslt 1.1.37 h2bbff1b_1 libzopfli 1.0.3 ha925a31_0 lz4-c 1.9.4 h2bbff1b_1 markdown-it-py 2.2.0 py311haa95532_1 markupsafe 2.1.3 py311h2bbff1b_0 matplotlib 3.8.4 py311haa95532_0 matplotlib-base 3.8.4 py311hf62ec03_0 matplotlib-inline 0.1.6 py311haa95532_0 mccabe 0.7.0 pyhd3eb1b0_0 mdurl 0.1.0 py311haa95532_0 mistune 2.0.4 py311haa95532_0 mkl 2023.1.0 h6b88ed4_46358 mkl-service 2.4.0 py311h2bbff1b_1 mkl_fft 1.3.8 py311h2bbff1b_0 mkl_random 1.2.4 py311h59b6b97_0 more-itertools 10.1.0 py311haa95532_0 mypy_extensions 1.0.0 py311haa95532_0 nbclient 0.8.0 py311haa95532_0 nbconvert 7.10.0 py311haa95532_0 nbformat 5.9.2 py311haa95532_0 nest-asyncio 1.6.0 py311haa95532_0 networkx 3.2.1 py311haa95532_0 numpy 1.26.4 py311hdab7c0b_0 numpy-base 1.26.4 py311hd01c5d8_0 numpydoc 1.5.0 py311haa95532_0 opencv 4.6.0 py311h5d08a89_5 opencv-python 4.10.0.82 pypi_0 pypi openjpeg 2.4.0 h4fc8c34_0 openssl 3.0.13 h2bbff1b_2 packaging 23.2 py311haa95532_0 pandocfilters 1.5.0 pyhd3eb1b0_0 paramiko 2.8.1 pyhd3eb1b0_0 parso 0.8.3 pyhd3eb1b0_0 pathspec 0.10.3 py311haa95532_0 pcre2 10.42 h0ff8eda_1 pexpect 4.8.0 pyhd3eb1b0_3 pickleshare 0.7.5 pyhd3eb1b0_1003 pillow 10.3.0 py311h2bbff1b_0 pip 24.0 py311haa95532_0 platformdirs 3.10.0 py311haa95532_0 pluggy 1.0.0 py311haa95532_1 ply 3.11 py311haa95532_0 prompt-toolkit 3.0.43 py311haa95532_0 prompt_toolkit 3.0.43 hd3eb1b0_0 psutil 5.9.0 py311h2bbff1b_0 ptyprocess 0.7.0 pyhd3eb1b0_2 pure_eval 0.2.2 pyhd3eb1b0_0 py-opencv 4.6.0 haa95532_5 pybind11-abi 5 hd3eb1b0_0 pycodestyle 2.11.1 py311haa95532_0 pycparser 2.21 pyhd3eb1b0_0 pydocstyle 6.3.0 py311haa95532_0 pyflakes 3.2.0 py311haa95532_0 pygments 2.15.1 py311haa95532_1 pylint 2.16.2 py311haa95532_0 pylint-venv 3.0.3 py311haa95532_0 pyls-spyder 0.4.0 pyhd3eb1b0_0 pynacl 1.5.0 py311h8cc25b3_0 pyparsing 3.0.9 py311haa95532_0 pyqt 5.15.10 py311hd77b12b_0 pyqt5-sip 12.13.0 py311h2bbff1b_0 pyqtwebengine 5.15.10 py311hd77b12b_0 pysocks 1.7.1 py311haa95532_0 python 3.11.9 he1021f5_0 python-dateutil 2.9.0post0 py311haa95532_2 python-fastjsonschema 2.16.2 py311haa95532_0 python-lsp-black 2.0.0 py311haa95532_0 python-lsp-jsonrpc 1.1.2 pyhd3eb1b0_0 python-lsp-server 1.10.0 py311haa95532_0 python-slugify 5.0.2 pyhd3eb1b0_0 pytoolconfig 1.2.6 py311haa95532_0 pytz 2024.1 py311haa95532_0 pywin32 305 py311h2bbff1b_0 pywin32-ctypes 0.2.2 py311haa95532_0 pyyaml 6.0.1 py311h2bbff1b_0 pyzmq 25.1.2 py311hd77b12b_0 qdarkstyle 3.2.3 pyhd3eb1b0_0 qstylizer 0.2.2 py311haa95532_0 qt-main 5.15.2 h879a1e9_9 qt-webengine 5.15.9 h5bd16bc_7 qtawesome 1.2.2 py311haa95532_0 qtconsole 5.5.1 py311haa95532_0 qtpy 2.4.1 py311haa95532_0 qtwebkit 5.212 h2bbfb41_5 referencing 0.30.2 py311haa95532_0 requests 2.32.2 py311haa95532_0 rich 13.3.5 py311haa95532_0 rope 1.12.0 py311haa95532_0 rpds-py 0.10.6 py311h062c2fa_0 rtree 1.0.1 py311h2eaa2aa_0 scikit-image 0.22.0 py311hb4ba03d_0 scipy 1.13.1 py311h9f229c6_0 setuptools 69.5.1 py311haa95532_0 sip 6.7.12 py311hd77b12b_0 six 1.16.0 pyhd3eb1b0_1 snappy 1.1.10 h6c2663c_1 snowballstemmer 2.2.0 pyhd3eb1b0_0 sortedcontainers 2.4.0 pyhd3eb1b0_0 soupsieve 2.5 py311haa95532_0 sphinx 5.0.2 py311haa95532_0 sphinxcontrib-applehelp 1.0.2 pyhd3eb1b0_0 sphinxcontrib-devhelp 1.0.2 pyhd3eb1b0_0 sphinxcontrib-htmlhelp 2.0.0 pyhd3eb1b0_0 sphinxcontrib-jsmath 1.0.1 pyhd3eb1b0_0 sphinxcontrib-qthelp 1.0.3 pyhd3eb1b0_0 sphinxcontrib-serializinghtml 1.1.5 pyhd3eb1b0_0 spyder 5.5.1 py311haa95532_0 spyder-kernels 2.5.0 py311haa95532_0 sqlite 3.45.3 h2bbff1b_0 stack_data 0.2.0 pyhd3eb1b0_0 tbb 2021.8.0 h59b6b97_0 text-unidecode 1.3 pyhd3eb1b0_0 textdistance 4.2.1 pyhd3eb1b0_0 three-merge 0.1.1 pyhd3eb1b0_0 tifffile 2023.4.12 py311haa95532_0 tinycss2 1.2.1 py311haa95532_0 tk 8.6.14 h0416ee5_0 toml 0.10.2 pyhd3eb1b0_0 tomli 2.0.1 py311haa95532_0 tomlkit 0.11.1 py311haa95532_0 tornado 6.3.3 py311h2bbff1b_0 traitlets 5.7.1 py311haa95532_0 tzdata 2024a h04d1e81_0 ujson 5.10.0 py311h5da7b33_0 unicodedata2 15.1.0 py311h2bbff1b_0 unidecode 1.2.0 pyhd3eb1b0_0 urllib3 2.2.1 py311haa95532_0 vc 14.2 h2eaa2aa_1 vs2015_runtime 14.29.30133 h43f2093_3 watchdog 4.0.1 py311haa95532_0 wcwidth 0.2.5 pyhd3eb1b0_0 webencodings 0.5.1 py311haa95532_1 whatthepatch 1.0.2 py311haa95532_0 wheel 0.43.0 py311haa95532_0 win_inet_pton 1.1.0 py311haa95532_0 wrapt 1.14.1 py311h2bbff1b_0 xz 5.4.6 h8cc25b3_1 yaml 0.2.5 he774522_0 yapf 0.40.2 py311haa95532_0 zeromq 4.3.5 hd77b12b_0 zfp 1.0.0 hd77b12b_0 zipp 3.17.0 py311haa95532_0 zlib 1.2.13 h8cc25b3_1 zstd 1.5.5 hd43e919_2 ```
moosemoose19 commented 3 months ago

I found the problem to be that when walking through the code line by line, ex. f9, that the error will occur. However, when walking through code, if i run the block of code containing the function that it will work. The issue is that i can execute code line by line, since it is expecting the function definition, and erroring out. Item is a non-issue, but perhaps an enhancement idea.