TypeError: runfile() got an unexpected keyword argument 'current_namespace'

Viewed 12744

I got the error message when trying to debug a python script:

debugfile('C:/Users/Wei-shan/Desktop/pythonScripts/simple pendulum.py', wdir='C:/Users/Wei-shan/Desktop/pythonScripts', current_namespace=True)
Traceback (most recent call last):

  File "C:\Users\Wei-shan\AppData\Local\Temp/ipykernel_19384/837447315.py", line 1, in <module>
    debugfile('C:/Users/Wei-shan/Desktop/pythonScripts/simple pendulum.py', wdir='C:/Users/Wei-shan/Desktop/pythonScripts', current_namespace=True)

  File "D:\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 589, in debugfile
    enter_debugger(

  File "D:\anaconda3\lib\site-packages\spyder_kernels\customize\spyderpdb.py", line 773, in enter_debugger
    debugger.run(code)

  File "D:\anaconda3\lib\site-packages\spyder_kernels\customize\spyderpdb.py", line 716, in run
    super(SpyderPdb, self).run(cmd, globals, locals)

  File "D:\anaconda3\lib\bdb.py", line 580, in run
    exec(cmd, globals, locals)

  File "<string>", line 1, in <module>

TypeError: runfile() got an unexpected keyword argument 'current_namespace'

Any suggestions? Thank you very much

3 Answers

This will be fixed in Spyder 5.1.2. In the meantime, downgrade the ipykernel package in the environment to 6.2.0:

conda activate my_env
conda install ipykernel=6.2.0

You should see something like:

The following packages will be DOWNGRADED:

  ipykernel                            6.4.1-py37h06a4308_1 --> 6.2.0-py37h06a4308_1

after which, restart spyder and it should be good.

For me, the error was fixed by completely uninstalling and reinstalling Spyder. It looks like the problem is that you have an outdated version of the spyder kernels. There was a change some time ago here. Maybe a simple

conda update --all

is enough. But i haven't tested this.

I faced the same problem too. Even uninstall/reinstall of spyder didn't help (in Anaconda-Navigator). Update says that all packages are up to date (including kernels). Creating a different environement in Anaconda-Navigator and installing spyder there shows also same problem...

Related