Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'spawn' object has no attribute 'ptyproc' #2

Open
lstagner opened this issue Jun 29, 2015 · 6 comments
Open

AttributeError: 'spawn' object has no attribute 'ptyproc' #2

lstagner opened this issue Jun 29, 2015 · 6 comments

Comments

@lstagner
Copy link
Owner

This issue was sent to me by email.

I am trying to download your IPython IDL kernel, running into the following error message in the command line after running:

rgntgw1-0-232-dhcp:~ benjamingerard$ ipython console --kernel IDL
IPython Console 3.1.0
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/Applications/Ureka/python/lib/python2.7/runpy.pyc in _run_module_as_main(mod_name='idl_kernel', alter_argv=1)
    160         sys.argv[0] = fname
    161     return _run_code(code, main_globals, None,
--> 162                      "__main__", fname, loader, pkg_name)
        fname = '/Applications/Ureka/variants/common/lib/python2.7/site-packages/idl_kernel.py'
        loader = <pkgutil.ImpLoader instance at 0x1007ba950>
        pkg_name = ''
    163
    164 def run_module(mod_name, init_globals=None,

/Applications/Ureka/python/lib/python2.7/runpy.pyc in _run_code(code=<code object <module> at 0x1007bb830, file "/App...b/python2.7/site-packages/idl_kernel.py", line 1>, run_globals={'EOF': <class 'pexpect.exceptions.EOF'>, 'IDLKernel': <class '__main__.IDLKernel'>, 'IPKernelApp': <class 'IPython.kernel.zmq.kernelapp.IPKernelApp'>, 'Kernel': <class 'IPython.kernel.zmq.kernelbase.Kernel'>, '__builtins__': <module '__builtin__' (built-in)>, '__doc__': None, '__file__': '/Applications/Ureka/variants/common/lib/python2.7/site-packages/idl_kernel.py', '__loader__': <pkgutil.ImpLoader instance>, '__name__': '__main__', '__package__': '', ...}, init_globals=None, mod_name='__main__', mod_fname='/Applications/Ureka/variants/common/lib/python2.7/site-packages/idl_kernel.py', mod_loader=<pkgutil.ImpLoader instance>, pkg_name='')
     70                        __loader__ = mod_loader,
     71                        __package__ = pkg_name)
---> 72     exec code in run_globals
        code = <code object <module> at 0x1007bb830, file "/Applications/Ureka/variants/common/lib/python2.7/site-packages/idl_kernel.py", line 1>
        run_globals = {'spawn': <class 'pexpect.pty_spawn.spawn'>, 'EOF': <class 'pexpect.exceptions.EOF'>, 'b64encode': <function b64encode at 0x101e37f50>, '__loader__': <pkgutil.ImpLoader instance at 0x1007ba950>, 'version_pat': <_sre.SRE_Pattern object at 0x1030ec9c0>, 're': <module 're' from '/Applications/Ureka/variants/common/lib/python2.7/re.pyc'>, 'tempfile': <module 'tempfile' from '/Applications/Ureka/python/lib/python2.7/tempfile.pyc'>, '__package__': '', 'publish_display_data': <function publish_display_data at 0x101ebd5f0>, '__version__': '0.4', '__file__': '/Applications/Ureka/variants/common/lib/python2.7/site-packages/idl_kernel.py', 'find_executable': <function find_executable at 0x1032865f0>, '__builtins__': <module '__builtin__' (built-in)>, 'glob': <function glob at 0x101c43c80>, 'rmtree': <function rmtree at 0x101b5ac80>, '__name__': '__main__', 'replwrap': <module 'pexpect.replwrap' from '/Applications/Ureka/variants/common/lib/python2.7/site-packages/pexpect/replwrap.pyc'>, 'Kernel': <class 'IPython.kernel.zmq.kernelbase.Kernel'>, 'locate_profile': <function locate_profile at 0x101cf00c8>, 'IDLKernel': <class '__main__.IDLKernel'>, 'signal': <module 'signal' (built-in)>, '__doc__': None, 'check_output': <function check_output at 0x101cbfb90>, 'IPKernelApp': <class 'IPython.kernel.zmq.kernelapp.IPKernelApp'>, 'os': <module 'os' from '/Applications/Ureka/variants/common/lib/python2.7/os.pyc'>}
     73     return run_globals
     74

/Applications/Ureka/variants/common/lib/python2.7/site-packages/idl_kernel.py in <module>()
    227 if __name__ == '__main__':
    228     from IPython.kernel.zmq.kernelapp import IPKernelApp
--> 229     IPKernelApp.launch_instance(kernel_class=IDLKernel)
        global IPKernelApp.launch_instance = <bound method MetaHasTraits.launch_instance of <class 'IPython.kernel.zmq.kernelapp.IPKernelApp'>>
        global kernel_class = undefined
        global IDLKernel = <class '__main__.IDLKernel'>

/Applications/Ureka/variants/common/lib/python2.7/site-packages/IPython/config/application.pyc in launch_instance(cls=<class 'IPython.kernel.zmq.kernelapp.IPKernelApp'>, argv=None, **kwargs={'kernel_class': <class '__main__.IDLKernel'>})
    571         """
    572         app = cls.instance(**kwargs)
--> 573         app.initialize(argv)
        app.initialize = <bound method IPKernelApp.initialize of <IPython.kernel.zmq.kernelapp.IPKernelApp object at 0x1036fcd90>>
        argv = None
    574         app.start()
    575

/Applications/Ureka/variants/common/lib/python2.7/site-packages/IPython/kernel/zmq/kernelapp.pyc in initialize(self=<IPython.kernel.zmq.kernelapp.IPKernelApp object>, argv=None)

/Applications/Ureka/variants/common/lib/python2.7/site-packages/IPython/config/application.pyc in catch_config_error(method=<function initialize>, app=<IPython.kernel.zmq.kernelapp.IPKernelApp object>, *args=(None,), **kwargs={})
     73     """
     74     try:
---> 75         return method(app, *args, **kwargs)
        method = <function initialize at 0x103703050>
        app = <IPython.kernel.zmq.kernelapp.IPKernelApp object at 0x1036fcd90>
        args = (None,)
        kwargs = {}
     76     except (TraitError, ArgumentError) as e:
     77         app.print_help()

/Applications/Ureka/variants/common/lib/python2.7/site-packages/IPython/kernel/zmq/kernelapp.pyc in initialize(self=<IPython.kernel.zmq.kernelapp.IPKernelApp object>, argv=None)
    353         self.init_io()
    354         self.init_signal()
--> 355         self.init_kernel()
        self.init_kernel = <bound method IPKernelApp.init_kernel of <IPython.kernel.zmq.kernelapp.IPKernelApp object at 0x1036fcd90>>
    356         # shell init steps
    357         self.init_path()

/Applications/Ureka/variants/common/lib/python2.7/site-packages/IPython/kernel/zmq/kernelapp.pyc in init_kernel(self=<IPython.kernel.zmq.kernelapp.IPKernelApp object>)
    308                                 log=self.log,
    309                                 profile_dir=self.profile_dir,
--> 310                                 user_ns=self.user_ns,
        global user_ns = undefined
        self.user_ns = None
    311         )
    312         kernel.record_ports(self.ports)

/Applications/Ureka/variants/common/lib/python2.7/site-packages/IPython/config/configurable.pyc in instance(cls=<class '__main__.IDLKernel'>, *args=(), **kwargs={'iopub_socket': <zmq.sugar.socket.Socket object>, 'log': <logging.Logger object>, 'parent': <IPython.kernel.zmq.kernelapp.IPKernelApp object>, 'profile_dir': <IPython.core.profiledir.ProfileDir object>, 'session': <IPython.kernel.zmq.session.Session object>, 'shell_streams': [<zmq.eventloop.zmqstream.ZMQStream object>, <zmq.eventloop.zmqstream.ZMQStream object>], 'stdin_socket': <zmq.sugar.socket.Socket object>, 'user_ns': None})
    335         # Create and save the instance
    336         if cls._instance is None:
--> 337             inst = cls(*args, **kwargs)
        inst = undefined
        cls = <class '__main__.IDLKernel'>
        args = ()
        kwargs = {'log': <logging.Logger object at 0x103709310>, 'parent': <IPython.kernel.zmq.kernelapp.IPKernelApp object at 0x1036fcd90>, 'shell_streams': [<zmq.eventloop.zmqstream.ZMQStream object at 0x10374c310>, <zmq.eventloop.zmqstream.ZMQStream object at 0x10374c590>], 'user_ns': None, 'iopub_socket': <zmq.sugar.socket.Socket object at 0x103732d50>, 'profile_dir': <IPython.core.profiledir.ProfileDir object at 0x1037094d0>, 'session': <IPython.kernel.zmq.session.Session object at 0x10373ca90>, 'stdin_socket': <zmq.sugar.socket.Socket object at 0x103732db8>}
    338             # Now make sure that the instance will also be returned by
    339             # parent classes' _instance attribute.

/Applications/Ureka/variants/common/lib/python2.7/site-packages/idl_kernel.py in __init__(self=<__main__.IDLKernel object>, **kwargs={'iopub_socket': <zmq.sugar.socket.Socket object>, 'log': <logging.Logger object>, 'parent': <IPython.kernel.zmq.kernelapp.IPKernelApp object>, 'profile_dir': <IPython.core.profiledir.ProfileDir object>, 'session': <IPython.kernel.zmq.session.Session object>, 'shell_streams': [<zmq.eventloop.zmqstream.ZMQStream object>, <zmq.eventloop.zmqstream.ZMQStream object>], 'stdin_socket': <zmq.sugar.socket.Socket object>, 'user_ns': None})
     51     def __init__(self, **kwargs):
     52         Kernel.__init__(self, **kwargs)
---> 53         self._start_idl()
        self._start_idl = <bound method IDLKernel._start_idl of <__main__.IDLKernel object at 0x10374c6d0>>
     54
     55         try:

/Applications/Ureka/variants/common/lib/python2.7/site-packages/idl_kernel.py in _start_idl(self=<__main__.IDLKernel object>)
     75             self._executable = find_executable("gdl")
     76             self._child  = spawn(self._executable,timeout = 300)
---> 77             self.idlwrapper = replwrap.REPLWrapper(self._child,u"GDL> ",None)
        self.idlwrapper = undefined
        global replwrap.REPLWrapper = <class 'pexpect.replwrap.REPLWrapper'>
        self._child = <pexpect.pty_spawn.spawn object at 0x10374c8d0>
        global None = undefined
     78         finally:
     79             signal.signal(signal.SIGINT, sig)

/Applications/Ureka/variants/common/lib/python2.7/site-packages/pexpect/replwrap.pyc in __init__(self=<pexpect.replwrap.REPLWrapper object>, cmd_or_spawn=<pexpect.pty_spawn.spawn object>, orig_prompt=u'GDL> ', prompt_change=None, new_prompt=u'[PEXPECT_PROMPT>', continuation_prompt=u'[PEXPECT_PROMPT+', extra_init_cmd=None)
     45             # Existing spawn instance has echo enabled, disable it
     46             # to prevent our input from being repeated to output.
---> 47             self.child.setecho(False)
        self.child.setecho = <bound method spawn.setecho of <pexpect.pty_spawn.spawn object at 0x10374c8d0>>
        global False = undefined
     48             self.child.waitnoecho()
     49

/Applications/Ureka/variants/common/lib/python2.7/site-packages/pexpect/pty_spawn.pyc in setecho(self=<pexpect.pty_spawn.spawn object>, state=False)
    381         Not supported on platforms where ``isatty()`` returns False.
    382         '''
--> 383         return self.ptyproc.setecho(state)
        self.ptyproc.setecho = undefined
        state = False
    384
    385         self.echo = state

AttributeError: 'spawn' object has no attribute 'ptyproc'

can you help me fix this or direct me to someone who can?

@lstagner
Copy link
Owner Author

If I were to hazard a guess I would say that some of your dependencies are out of date. I would suggest updating your dependencies such as Pexpect, pyzmq, and IPython. The easiest way to do this is to install the anaconda python distribution for the python 3 series. It installs in your local directory so you dont need to worry about permissions.

If that doesn't work let me know. Its been a while since I worked on this so it may very well be broken.

@lstagner
Copy link
Owner Author

lstagner commented Jul 9, 2015

It looks like you are using the development version of pexpect. Try switching to Pexpect 3.3

@bege5080
Copy link

bege5080 commented Jul 9, 2015

I am now using anaconda and Pexpect 3.3, but still get the following error:

Admins-MacBook-Pro-6:~ benjamingerard$ ipython console --kernel IDL
WARNING: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.

IPython Console 3.2.0

ValueError Traceback (most recent call last)
/Users/benjamingerard/anaconda/lib/python2.7/runpy.pyc in _run_module_as_main(mod_name='idl_kernel', alter_argv=1)
160 sys.argv[0] = fname
161 return _run_code(code, main_globals, None,
--> 162 "main", fname, loader, pkg_name)
fname = '/Users/benjamingerard/.local/lib/python2.7/site-packages/idl_kernel.py'
loader = <pkgutil.ImpLoader instance at 0x1005dac20>
pkg_name = ''
163
164 def run_module(mod_name, init_globals=None,

/Users/benjamingerard/anaconda/lib/python2.7/runpy.pyc in _run_code(code=<code object at 0x1005ed230, file "/Use...b/python2.7/site-packages/idl_kernel.py", line 1>, run_globals={'EOF': <class 'pexpect.EOF'>, 'IDLKernel': <class 'main.IDLKernel'>, 'IPKernelApp': <class 'IPython.kernel.zmq.kernelapp.IPKernelApp'>, 'Kernel': <class 'IPython.kernel.zmq.kernelbase.Kernel'>, 'builtins': <module 'builtin' (built-in)>, 'doc': None, 'file': '/Users/benjamingerard/.local/lib/python2.7/site-packages/idl_kernel.py', 'loader': <pkgutil.ImpLoader instance>, 'name': 'main', 'package': '', ...}, init_globals=None, mod_name='main', mod_fname='/Users/benjamingerard/.local/lib/python2.7/site-packages/idl_kernel.py', mod_loader=<pkgutil.ImpLoader instance>, pkg_name='')
70 loader = mod_loader,
71 package = pkg_name)
---> 72 exec code in run_globals
code = <code object at 0x1005ed230, file "/Users/benjamingerard/.local/lib/python2.7/site-packages/idl_kernel.py", line 1>
run_globals = {'spawn': <class 'pexpect.spawn'>, 'EOF': <class 'pexpect.EOF'>, 'b64encode': <function b64encode at 0x102f311b8>, 'loader': <pkgutil.ImpLoader instance at 0x1005dac20>, 'version_pat': <_sre.SRE_Pattern object at 0x1036b1030>, 're': <module 're' from '/Users/benjamingerard/anaconda/lib/python2.7/re.pyc'>, 'tempfile': <module 'tempfile' from '/Users/benjamingerard/anaconda/lib/python2.7/tempfile.pyc'>, 'package': '', 'publish_display_data': <function publish_display_data at 0x102fc2e60>, 'version': '0.4', 'file': '/Users/benjamingerard/.local/lib/python2.7/site-packages/idl_kernel.py', 'find_executable': <function find_executable at 0x1036a7d70>, 'builtins': <module 'builtin' (built-in)>, 'glob': <function glob at 0x102d2f8c0>, 'rmtree': <function rmtree at 0x102a527d0>, 'name': 'main', 'replwrap': <module 'pexpect.replwrap' from '/Users/benjamingerard/anaconda/lib/python2.7/site-packages/pexpect/replwrap.pyc'>, 'Kernel': <class 'IPython.kernel.zmq.kernelbase.Kernel'>, 'locate_profile': <function locate_profile at 0x102d945f0>, 'IDLKernel': <class 'main.IDLKernel'>, 'signal': <module 'signal' (built-in)>, 'doc': None, 'check_output': <function check_output at 0x102d616e0>, 'IPKernelApp': <class 'IPython.kernel.zmq.kernelapp.IPKernelApp'>, 'os': <module 'os' from '/Users/benjamingerard/anaconda/lib/python2.7/os.pyc'>}
73 return run_globals
74

/Users/benjamingerard/.local/lib/python2.7/site-packages/idl_kernel.py in ()
216 if name == 'main':
217 from IPython.kernel.zmq.kernelapp import IPKernelApp
--> 218 IPKernelApp.launch_instance(kernel_class=IDLKernel)
global IPKernelApp.launch_instance = <bound method MetaHasTraits.launch_instance of <class 'IPython.kernel.zmq.kernelapp.IPKernelApp'>>
global kernel_class = undefined
global IDLKernel = <class 'main.IDLKernel'>

/Users/benjamingerard/anaconda/lib/python2.7/site-packages/IPython/config/application.pyc in launch_instance(cls=<class 'IPython.kernel.zmq.kernelapp.IPKernelApp'>, argv=None, **kwargs={'kernel_class': <class 'main.IDLKernel'>})
571 """
572 app = cls.instance(**kwargs)
--> 573 app.initialize(argv)
app.initialize = <bound method IPKernelApp.initialize of <IPython.kernel.zmq.kernelapp.IPKernelApp object at 0x1036eac50>>
argv = None
574 app.start()
575

/Users/benjamingerard/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/kernelapp.pyc in initialize(self=<IPython.kernel.zmq.kernelapp.IPKernelApp object>, argv=None)

/Users/benjamingerard/anaconda/lib/python2.7/site-packages/IPython/config/application.pyc in catch_config_error(method=, app=<IPython.kernel.zmq.kernelapp.IPKernelApp object>, _args=(None,), *_kwargs={})
73 """
74 try:
---> 75 return method(app, _args, *_kwargs)
method = <function initialize at 0x1036f5230>
app = <IPython.kernel.zmq.kernelapp.IPKernelApp object at 0x1036eac50>
args = (None,)
kwargs = {}
76 except (TraitError, ArgumentError) as e:
77 app.print_help()

/Users/benjamingerard/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/kernelapp.pyc in initialize(self=<IPython.kernel.zmq.kernelapp.IPKernelApp object>, argv=None)
353 self.init_io()
354 self.init_signal()
--> 355 self.init_kernel()
self.init_kernel = <bound method IPKernelApp.init_kernel of <IPython.kernel.zmq.kernelapp.IPKernelApp object at 0x1036eac50>>
356 # shell init steps
357 self.init_path()

/Users/benjamingerard/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/kernelapp.pyc in init_kernel(self=<IPython.kernel.zmq.kernelapp.IPKernelApp object>)
308 log=self.log,
309 profile_dir=self.profile_dir,
--> 310 user_ns=self.user_ns,
global user_ns = undefined
self.user_ns = None
311 )
312 kernel.record_ports(self.ports)

/Users/benjamingerard/anaconda/lib/python2.7/site-packages/IPython/config/configurable.pyc in instance(cls=<class 'main.IDLKernel'>, _args=(), *_kwargs={'iopub_socket': <zmq.sugar.socket.Socket object>, 'log': <logging.Logger object>, 'parent': <IPython.kernel.zmq.kernelapp.IPKernelApp object>, 'profile_dir': <IPython.core.profiledir.ProfileDir object>, 'session': <IPython.kernel.zmq.session.Session object>, 'shell_streams': [<zmq.eventloop.zmqstream.ZMQStream object>, <zmq.eventloop.zmqstream.ZMQStream object>], 'stdin_socket': <zmq.sugar.socket.Socket object>, 'user_ns': None})
335 # Create and save the instance
336 if cls._instance is None:
--> 337 inst = cls(_args, *_kwargs)
inst = undefined
cls = <class 'main.IDLKernel'>
args = ()
kwargs = {'log': <logging.Logger object at 0x1037031d0>, 'parent': <IPython.kernel.zmq.kernelapp.IPKernelApp object at 0x1036eac50>, 'shell_streams': [<zmq.eventloop.zmqstream.ZMQStream object at 0x10376e290>, <zmq.eventloop.zmqstream.ZMQStream object at 0x10376e510>], 'user_ns': None, 'iopub_socket': <zmq.sugar.socket.Socket object at 0x10373ef58>, 'profile_dir': <IPython.core.profiledir.ProfileDir object at 0x103703390>, 'session': <IPython.kernel.zmq.session.Session object at 0x10374ea10>, 'stdin_socket': <zmq.sugar.socket.Socket object at 0x103765050>}
338 # Now make sure that the instance will also be returned by
339 # parent classes' _instance attribute.

/Users/benjamingerard/.local/lib/python2.7/site-packages/idl_kernel.py in init(self=<main.IDLKernel object>, *_kwargs={'iopub_socket': <zmq.sugar.socket.Socket object>, 'log': <logging.Logger object>, 'parent': <IPython.kernel.zmq.kernelapp.IPKernelApp object>, 'profile_dir': <IPython.core.profiledir.ProfileDir object>, 'session': <IPython.kernel.zmq.session.Session object>, 'shell_streams': [<zmq.eventloop.zmqstream.ZMQStream object>, <zmq.eventloop.zmqstream.ZMQStream object>], 'stdin_socket': <zmq.sugar.socket.Socket object>, 'user_ns': None})
51 def init(self, *_kwargs):
52 Kernel.init(self, **kwargs)
---> 53 self._start_idl()
self._start_idl = <bound method IDLKernel._start_idl of <main.IDLKernel object at 0x10376e650>>
54
55 try:

/Users/benjamingerard/.local/lib/python2.7/site-packages/idl_kernel.py in _start_idl(self=<main.IDLKernel object>)
75 self._executable = find_executable("gdl")
76 self._child = spawn(self._executable,timeout = 300)
---> 77 self.idlwrapper = replwrap.REPLWrapper(self._child,u"GDL> ",None)
self.idlwrapper = undefined
global replwrap.REPLWrapper = <class 'pexpect.replwrap.REPLWrapper'>
self._child = <pexpect.spawn object at 0x10376e850>
global None = undefined
78 finally:
79 signal.signal(signal.SIGINT, sig)

/Users/benjamingerard/anaconda/lib/python2.7/site-packages/pexpect/replwrap.pyc in init(self=<pexpect.replwrap.REPLWrapper object>, cmd_or_spawn=<pexpect.spawn object>, orig_prompt=u'GDL> ', prompt_change=None, new_prompt=u'[PEXPECT_PROMPT>', continuation_prompt=u'[PEXPECT_PROMPT+')
41 # Existing spawn instance has echo enabled, disable it
42 # to prevent our input from being repeated to output.
---> 43 self.child.setecho(False)
self.child.setecho = <bound method spawn.setecho of <pexpect.spawn object at 0x10376e850>>
global False = undefined
44 self.child.waitnoecho()
45

/Users/benjamingerard/anaconda/lib/python2.7/site-packages/pexpect/init.pyc in setecho(self=<pexpect.spawn object>, state=False)
878
879 try:
--> 880 attr = termios.tcgetattr(self.child_fd)
attr = undefined
global termios.tcgetattr =
self.child_fd = -1
881 except termios.error as err:
882 if err.args[0] == errno.EINVAL:

ValueError: file descriptor cannot be a negative integer (-1)
ERROR: Kernel did not respond

Shutting down kernel

@lstagner
Copy link
Owner Author

lstagner commented Jul 9, 2015

Can you tell me what

from distutils.spawn import find_executable
print(find_executable("idl"))

gives when you run it in the python console

@bege5080
Copy link

bege5080 commented Jul 9, 2015

In [44]: from distutils.spawn import find_executable

In [45]: print(find_executable("idl"))
None

@lstagner
Copy link
Owner Author

lstagner commented Jul 9, 2015

That's the problem. So this can be caused by two things

  1. You don't have IDL installed
  2. Its something to do with running in a virtualenv

The first you can fix by installing IDL. The second is more complicated since I am really not familiar with virtualenv. You may try running hash -r in the (bash) command line as suggested by this ipython issue

If neither of those things work I would suggest opening an ipython issue, referencing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants