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

ipython console does not open up. #1586

Closed
spyder-bot opened this issue Feb 17, 2015 · 6 comments
Closed

ipython console does not open up. #1586

spyder-bot opened this issue Feb 17, 2015 · 6 comments

Comments

@spyder-bot
Copy link
Collaborator

From yacc...@gmail.com on 2013-09-30T09:56:48Z

Spyder Version: 2.2.3
Python Version: 2.7.5
Qt Version : 4.8.4, PyQt4 (API v2) 4.10.1 on Windows
pyflakes 0.5.0 : None (OK)
pep8 >=0.6 : 1.4.5 (OK)
IPython >=0.13;<1.0: 0.13.2 (OK)
rope >=0.9.2 : 0.9.4 (OK)
sphinx >=0.6.6 : 1.1.3 (OK)
matplotlib >=1.0 : None (NOK)
sympy >=0.7.0 : None (NOK)
pylint >=0.25 : 0.27.0 (OK)

What steps will reproduce the problem?

  1. Right Click in IPython console tab, click on "Open an IPython console".
    1. IPython console tab stays empty.
    2. Console tab "IP: Kernel" shows:
      'import sitecustomize' failed; use -v for traceback
      [IPKernelApp] To connect another client to this kernel, use:
      [IPKernelApp] --existing kernel-17536.json
    3. Sidenote: trying to connect to an existing kernel works.
    4. Sidenote: the kernel mentioned in the console tab does not work, so I guess the ipython kernel dies. What is the expected output? What do you see instead? Expected behaviour would be that an ipython console shows.

Please provide any additional information below

. Most irritating here is that it seems very hard to configure the -v for the child python process.

Original issue: http://code.google.com/p/spyderlib/issues/detail?id=1586

@spyder-bot
Copy link
Collaborator Author

From yacc...@gmail.com on 2013-09-30T08:04:35Z

Running with SPYDER_DEBUG=4 I get:

Traceback (most recent call last):^M
File "c:\python27\lib\site.py", line 498, in execsitecustomize^M
import sitecustomize^M
File "c:\python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 294, in ^M
from IPython.core.debugger import Pdb as ipyPdb^M
File "c:\python27\lib\site-packages\IPython__init__.py", line 43, in ^M
from .config.loader import Config^M
File "c:\python27\lib\site-packages\IPython\config__init__.py", line 16, in ^M
from .application import *^M
File "c:\python27\lib\site-packages\IPython\config\application.py", line 67, in ^M
""".strip().format(app=os.path.basename(sys.argv[0]))^M
AttributeError: 'module' object has no attribute 'argv'^M

@spyder-bot
Copy link
Collaborator Author

From yacc...@gmail.com on 2013-09-30T08:08:08Z

sys.argv missing seems to be an artifact of sitecustomize.py being run really early.

@spyder-bot
Copy link
Collaborator Author

From yacc...@gmail.com on 2013-09-30T08:14:48Z

Not sure how to fix that, spyder's sitecustomize does import IPython.core.debugger which seems to rely on sys.argv, which is not available at sitecustomize time.

@spyder-bot
Copy link
Collaborator Author

From yacc...@gmail.com on 2013-09-30T08:18:05Z

#XXX If Matplotlib is not imported first, the next IPython import will fail

Well, this is marked just a little above the failing ipython import => I have no matplotlib installed (and pip install on my windows box fails with some missing header file).

I do not need matplotlib for my use case, but it seems the case that without matplotlib ipython console is broken for spyder.

@spyder-bot
Copy link
Collaborator Author

From yacc...@gmail.com on 2013-09-30T08:28:49Z

Ok, changing the IPython import to provide an sys.argv seems to fix it, should be benign:

1.) ipython uses sys.argv[0] only for help strings.
2.) the change uses a visiable sentinel string
3.) the change removes sys.argv after the place that needs it.

the needed change is: (no patch file, I've patched this in a deployed version of spyder, on a Windows box, OTOH, it's a rather simple change, and somebody needs to review it anyway before applying it.)

spyderlib/widgets/externalshell/sitecustomize.py around line 294:

if not hasattr(sys, "argv"):
    sys.argv = ["IPYTHON_IMPORT_WORKAROUND"]
from IPython.core.debugger import Pdb as ipyPdb
if getattr(sys, "argv", None) == ["IPYTHON_IMPORT_WORKAROUND"]:
    del sys.argv

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2015-01-01T16:00:13Z

I fixed this one a long time ago

Status: Duplicate
Mergedinto: 1473

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

No branches or pull requests

1 participant