Spyder: runfile is not defined ?

Created on 17 Sep 2016  路  33Comments  路  Source: spyder-ide/spyder

Description of your problem

What steps will reproduce the problem?

  1. on latest spyder 2016-09-15 type a script on editor and run it (in winpython latest)
  2. ipython console says "runfile" doesn't exist ?
  3. 3.

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

runfile is found and there is no issue

Please provide any additional information below
spyder-20160917runfile

Versions and main components

  • Spyder Version: github 2016-09-16
  • Python Version: 3.5
  • Operating system: Windows10 (winpython)

    Dependencies

Please go to the menu entry Help > Optional Dependencies (or
Help > Dependencies), press the button Copy to clipboard
and paste the contents below:
jedi >=0.8.1 : 0.9.0 (OK)
matplotlib >=1.0 : 2.0.0b4 (OK)
nbconvert >=4.0 : 4.2.0 (OK)
numpy >=1.7 : 1.11.1 (OK)
pandas >=0.13.1 : 0.19.0rc1 (OK)
pep8 >=0.6 : 1.7.0 (OK)
pyflakes >=0.6.0 : 1.3.0 (OK)
pygments >=2.0 : 2.1.3 (OK)
pylint >=0.25 : 1.6.4 (OK)
qtconsole >=4.2.0: 4.2.1 (OK)
rope >=0.9.4 : 0.9.4-1 (OK)
sphinx >=0.6.6 : 1.4.6 (OK)
sympy >=0.7.3 : 1.0 (OK)

Most helpful comment

I have the same problem with Spyder version 3.0.0b7 installed with conda. I think the problem is that spyder/utils/site/sitecustomize.py is not installed. I don't understand how the package get built, but comparing the spyder/utils/site subdirectory (which is not installed) with the spyder/utils/external, perhaps the problem is a missing spyder/utils/site/__init__.py file?

When running Spyder from a git clone using bootstrap.py, the error disappears.

All 33 comments

there is no issue if I choose to "run in a dedicated python console" or in an "terminal external windows"

What is your ipython version ?

I'll take a look at this one. It's very strange that runfile doesn't appear defined.

@Nodd Ipython 5.1.0 (all the latest officials wheels from Jupyter/Ipython system..)

Do you need me to check Beta6 was ok ? (I would think problems are with the big change https://github.com/spyder-ide/spyder/pull/2878 merged 3 days ago)

@stonebig, this means (most probably) that there's an error in sitecustomize. Please run in a console:

set SPYDER_DEBUG=3
spyder --show-console

and check if there are any errors printed in our Python or IPython consoles

this does nothing but showing 1 second the spyder "splash" screen. and no DOS error.

But there have to be errors printed in our Python consoles, at least, or something saying that sitecustomize failed to load.

Can't you see anything like that?

well, for my case I should type:

set SPYDER_DEBUG=3
spyder.exe --show-console

yet nothing visible... trying to see further, it seems I have hidden "Console Windows Host" processes in background

Not sure whether this is helpful:

I see the same issue of 'NameError: name 'runfile' is not defined' and also the other issue
At spyder start, Kernel is said "dead and restarting" a lot of times (on a slow pc) #3429.

(py3x) set SPYDER_DEBUG=3
(py3x) C:Userswt>spyder.exe --show-console
Traceback (most recent call last):
File "C:Anacondaenvspy3xScriptsspyder-script.py", line 2, in start.main()
File "C:Anacondaenvspy3xlibsite-packagesspyderappstart.py", line 104, in main mainwindow.main()
File "C:Anacondaenvspy3xlibsite-packagesspyderappmainwindow.py", line 2955, in main or options.optimize)
File "C:Anacondaenvspy3xlibsite-packagesspyderutilswindows.py", line 33, in set_attached_console_visible
return bool(ShowWindow(console_window_handle, flag[state]))
KeyError: 3

Changing the debug level:

(py3x) set SPYDER_DEBUG=0'
(py3x) C:Userswt>spyder.exe --show-console

I get many lines of:
QWindowsFontDataBase::createEngine: CreateFontFromLOGFONT failed()

And whenever spyder was maximized in the previous run I also get one line of:
QWindowsWindow::setGeometry: Unable to set geometry 3780x2220+45+102 on QWidgetWindow/'MainWindowClassWindow'. Resulting geometry: 3780x2088+45+102 (frame: 16, 72, 16, 16, custom margin: 0, 0, 0, 0, minimum size: 368x263, maximum size: 16777215x16777215).

spyder --reset doesn't change the subsequent behaviour.

I have windows 10, anaconda, display 3840x2160 (with 250% size scaling)

Version and main components

  • Spyder Version: 3.0.0.dev0
  • Python Version: 3.5.1
  • Qt Versions: 5.6.0, PyQt5 5.6 on Windows

Dependencies

jedi >=0.8.1     :  0.9.0 (OK)
matplotlib >=1.0 :  1.5.1 (OK)
nbconvert >=4.0  :  4.1.0 (OK)
numpy >=1.7      :  1.10.4 (OK)
pandas >=0.13.1  :  0.18.0 (OK)
pep8 >=0.6       :  1.7.0 (OK)
pyflakes >=0.6.0 :  1.1.0 (OK)
pygments >=2.0   :  2.1.3 (OK)
pylint >=0.25    :  1.5.4 (OK)
qtconsole >=4.2.0:  4.2.0 (OK)
rope >=0.9.4     :  0.9.4-1 (OK)
sphinx >=0.6.6   :  1.3.1 (OK)
sympy >=0.7.3    :  1.0 (OK)

Thanks, but the error in sitecustomize should be printed in our Python consoles, not directly in the terminal where Spyder was started. Please try to take a look there :-)

activating the console by hand, I see nothing there, but the death of the kernel:
spyder-20160917runfile3

I don't know then :-/ I don't understand how runfile is not defined. I can't see any error in my Windows tests.

another look, at the sys.path:

import sys

sys.path
Out[4]: 
['',
 'C:\\WinPython\\basedir35\\buildQt5\\winpython-32bit-3.5.x.3\\python-3.5.2\\lib\\site-packages\\spyder\\utils\\site',
 'C:\\WinPython\\basedir35\\buildQt5\\winpython-32bit-3.5.x.3\\python-3.5.2\\python35.zip',
 'C:\\WinPython\\basedir35\\buildQt5\\winpython-32bit-3.5.x.3\\python-3.5.2\\DLLs',
 'C:\\WinPython\\basedir35\\buildQt5\\winpython-32bit-3.5.x.3\\python-3.5.2\\lib',
 'C:\\WinPython\\basedir35\\buildQt5\\winpython-32bit-3.5.x.3\\python-3.5.2',
 'C:\\WinPython\\basedir35\\buildQt5\\winpython-32bit-3.5.x.3\\python-3.5.2\\lib\\site-packages',
 'C:\\WinPython\\basedir35\\buildQt5\\winpython-32bit-3.5.x.3\\python-3.5.2\\lib\\site-packages\\win32',
 'C:\\WinPython\\basedir35\\buildQt5\\winpython-32bit-3.5.x.3\\python-3.5.2\\lib\\site-packages\\win32\\lib',
 'C:\\WinPython\\basedir35\\buildQt5\\winpython-32bit-3.5.x.3\\python-3.5.2\\lib\\site-packages\\Pythonwin',
 'C:\\WinPython\\basedir35\\buildQt5\\winpython-32bit-3.5.x.3\\python-3.5.2\\lib\\site-packages\\IPython\\extensions',
 'C:\\WinPython\\basedir35\\buildQt5\\winpython-32bit-3.5.x.3\\settings\\.ipython']

there is no possible effect of Matplotlib2.0.0b4 ? (I see in an old changelog "sitecustomize error when using Matplotlib 1.5 with Python 2")

error also there with PyQt4

Maybe, I haven't tested with Matplotlib 2.0.0b4. Could you test with 1.5.3?

will do. also maybe the kernel initial death is generating new kernel with "runfile" lost ?

same error with Matplotlib 1.5.3...
will now try with earlier build of Spyder (3.0.0b6) ... b6 works like a charm

a side-remark, First time I start a just created WinPython, Spyder tries to go to internet. never figured why, as I did put the parameter "check for Update on startup" to "False"

other check: it fails with Spyder-3.0.0b7 official wheel, on Qt5.7.0 Python3.5.2

Hello,

I upgraded to 3.0.0b7 and this issue started immediately
NameError: name 'runfile' is not defined

I'm on Ubuntu 14.04.3

Idem on OSX 10.11.6
The first thing I see in the IPython console is:
Kernel Died. Restarting.

I also have:
NameError: name 'debugfile' is not defined

I had the same problem after upgrading from 3.0.0b4 to 3.0.0b7. The error seemed to disappear when I ran sitecustomize.py manually from within Spyder 3 (from the folder \Python3.4\Lib\site-packages\spyder\widgets\externalshell). I suspect some kind of _path_ error. After adding the folder externalshell folder to the PYTHONPATH in Spyder (through PYTHONPATH manager in the Tools menu), it seems the _runfile is not defined_ error stays away (also after a refresh restart).

I have the same problem with Spyder version 3.0.0b7 installed with conda. I think the problem is that spyder/utils/site/sitecustomize.py is not installed. I don't understand how the package get built, but comparing the spyder/utils/site subdirectory (which is not installed) with the spyder/utils/external, perhaps the problem is a missing spyder/utils/site/__init__.py file?

When running Spyder from a git clone using bootstrap.py, the error disappears.

I confirm @jitseniesen suggestion works. I copied spyder/utils/introspection/init.py to spyder/utils/site/init.py and rebuild the wheel, and "runfile" is found again

+1 for this problem when installed with conda. I used stonebig's suggestion (git clone, copied spyder/utils/introspection/__init__.py to spyder/utils/site/__init__.py) and used python setup.py install to solve this issue.

Yes, the problem is the spyder/utils/site directory didn't get packaged because of the lack of an __init__.py file in that dir (as @jitseniesen suggested ;-).

I'll solve this problem right away and release beta8!

Yes, the problem is the spyder/utils/site directory didn't get packaged because of the lack of an __init__.pyfile in that dir (as @jitseniesen suggested ;-).

It was the comment by @hoogenm that put me on the right track.

If possibe, it would be nice to have the black DOS window solved in beta8 also (if it's an easy fix)

@stonebig, It'll be there too :-)

I'm getting this issue in Spyder 3.1.4 with Python 3.6. I checked both spyder/utils/site and spyder/utils/introspection/. Both of these contain the init.py file. I thought this problem was already fixed? How can I fix it now?

I'm having the same issue with Spyder 3.2.3 with python 3.6
Traceback (most recent call last):

File "", line 1, in
runfile('/Users/calebbowyer/Documents/Python/HW3_py3.py', wdir='/Users/calebbowyer/Documents/Python')

NameError: name 'runfile' is not defined

IPython >=4.0 : 7.2.0 (OK)
cython >=0.21 : 0.29.2 (OK)
jedi >=0.9.0 : 0.13.2 (OK)
matplotlib >=2.0.0: 3.0.2 (OK)
nbconvert >=4.0 : 5.4.0 (OK)
numpy >=1.7 : 1.15.4 (OK)
pandas >=0.13.1 : 0.23.4 (OK)
psutil >=0.3 : 5.4.8 (OK)
pycodestyle >=2.3 : 2.4.0 (OK)
pyflakes >=0.6.0 : 2.0.0 (OK)
pygments >=2.0 : 2.3.1 (OK)
pylint >=0.25 : 2.2.2 (OK)
qtconsole >=4.2.0 : 4.4.3 (OK)
rope >=0.9.4 : 0.11.0 (OK)
sphinx >=0.6.6 : 1.8.2 (OK)
sympy >=0.7.3 : 1.3 (OK)

Was this page helpful?
0 / 5 - 0 ratings