Home Download Buy Blog Forum Support

Opening ipython via plugin

Opening ipython via plugin

Postby prev on Fri Sep 13, 2013 1:28 am

Hi there,

I added the following plugin to sublime text 2 which is meant to open the ipython qt console:


Code: Select all
import sublime, sublime_plugin
from subprocess import call
# import os

class ipythonQtCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        call(["start","ipython", "qtconsole", "--pylab", "--ConsoleWidget.font_size=9", "--ConsoleWidget.font_family='Consolas'"],shell=True)



Initially it worked just fine, i.e. the plugin opened an ipython shell. I then added a menu item and a key binding. At some point something must have gone wrong since now I get this error when I run the plugin:

Code: Select all
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Chris\Python27\lib\site-packages\IPython\__init__.py", line 43, in <
odule>
    from .config.loader import Config
  File "C:\Chris\Python27\lib\site-packages\IPython\config\__init__.py", line 1
, in <module>
    from .application import *
  File "C:\Chris\Python27\lib\site-packages\IPython\config\application.py", lin
31, in <module>
    from IPython.config.configurable import SingletonConfigurable
  File "C:\Chris\Python27\lib\site-packages\IPython\config\configurable.py", li
e 31, in <module>
    from loader import Config
  File "C:\Chris\Python27\lib\site-packages\IPython\config\loader.py", line 32,
in <module>
    from IPython.utils.path import filefind, get_ipython_dir
  File "C:\Chris\Python27\lib\site-packages\IPython\utils\path.py", line 29, in
<module>
    from IPython.utils.process import system
  File "C:\Chris\Python27\lib\site-packages\IPython\utils\process.py", line 25,
in <module>
    from ._process_win32 import _find_cmd, system, getoutput, AvoidUNCPath, arg
split
  File "C:\Chris\Python27\lib\site-packages\IPython\utils\_process_win32.py", l
ne 21, in <module>
    import ctypes
  File "C:\Chris\Python27\lib\ctypes\__init__.py", line 10, in <module>
    from _ctypes import Union, Structure, Array
ImportError: Module use of python26.dll conflicts with this version of Python.



I tested the script by running it line by line in the st2 shell itself and it is the last line call([...]) that causes the error. I find this a little strange since the command works ok when calling it from somewhere else, e.g. ipython itself.

There seems to be a conflict between st2's python and my system python... Does anybody have an idea of how I can get around this?

Thanks!
P
prev
 
Posts: 2
Joined: Thu Sep 12, 2013 11:26 pm

Re: Opening ipython via plugin

Postby prev on Fri Sep 13, 2013 4:56 am

I changed
Code: Select all
call(["start",...])
to
Code: Select all
os.system("start ...")
and now it works again, i.e. it opens an ipython shell.
prev
 
Posts: 2
Joined: Thu Sep 12, 2013 11:26 pm


Return to Plugin Development

Who is online

Users browsing this forum: ZaLiTHkA and 7 guests