elpaso / qgis-ipythonconsole

IPython QGIS plugin
11 stars 7 forks source link

plugin can't find Ipython on osgeo4w-64 #3

Open spaceof7 opened 9 years ago

spaceof7 commented 9 years ago

Im trying to get the plugin(version 1.0) to work in QGIS 2.8.1 on windows installed with OSGEO4W 64-bit. I have Ipython installed via pip (to make sure it is installed i checked the C:\OSGeo4W64\apps\Python27\Lib\site-packages\ folder for IPython and i can import IPython from the QGIS python console) but when I try to launch the plugin I get an error window telling me that IPython is not installed.

elpaso commented 9 years ago

Something went wrong when importing IPython in the lines below: https://github.com/elpaso/qgis-ipythonconsole/blob/master/IPyConsole.py#L208

You might try to track it down by printing the exception catched at: https://github.com/elpaso/qgis-ipythonconsole/blob/master/IPyConsole.py#L337

change to something like

    except ImportError, e:
        QMessageBox.information(self.iface.mainWindow(), _tr(u'Error'), _tr(u'%s') % e)

(untested).

spaceof7 commented 9 years ago

That worked for identifying the problem, thanks. The problem was that zmq wasn't installed. I installed it with pip install "ipython[all]" in case there were other optional dependencies I was missing.

But now i get a python error, it looks like the plugin can't load zmq. i made sure zmq was in the site- packages folder and I can import zmq from a regular python or ipython prompt but I can't import it from the QGIS python prompt.

Traceback (most recent call last):
  File "C:/Users/Administrator/.qgis2/python/plugins\IPyConsole\IPyConsole.py", line 125, in default
    self.run(dock=(self.get_settings('default_window_mode', DEFAULT_WINDOW_MODE) == 'docked'))
  File "C:/Users/Administrator/.qgis2/python/plugins\IPyConsole\IPyConsole.py", line 209, in run
    from IPython.qt.inprocess import QtInProcessKernelManager
  File "C:/OSGEO4~1/apps/qgis-rel-dev/./python\qgis\utils.py", line 478, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\OSGEO4~1\apps\Python27\lib\site-packages\IPython\qt\inprocess.py", line 6, in 
    from IPython.kernel.inprocess import (
  File "C:/OSGEO4~1/apps/qgis-rel-dev/./python\qgis\utils.py", line 478, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\OSGEO4~1\apps\Python27\lib\site-packages\IPython\kernel\__init__.py", line 4, in 
    from . import zmq
  File "C:/OSGEO4~1/apps/qgis-rel-dev/./python\qgis\utils.py", line 478, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\OSGEO4~1\apps\Python27\lib\site-packages\IPython\kernel\zmq\__init__.py", line 8, in 
    check_for_zmq('13', 'IPython.kernel.zmq')
  File "C:\OSGEO4~1\apps\Python27\lib\site-packages\IPython\utils\zmqrelated.py", line 10, in check_for_zmq
    import zmq
  File "C:/OSGEO4~1/apps/qgis-rel-dev/./python\qgis\utils.py", line 478, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\OSGEO4~1\apps\Python27\lib\site-packages\zmq\__init__.py", line 25, in 
    _libsodium = ctypes.cdll.LoadLibrary(bundled_sodium[0])
  File "C:\OSGEO4~1\apps\Python27\lib\ctypes\__init__.py", line 443, in LoadLibrary
    return self._dlltype(name)
  File "C:\OSGEO4~1\apps\Python27\lib\ctypes\__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found

Python version:
2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]

QGIS version:
2.8.1-Wien Wien, 6ada2b6

Python path: ['C:/Users/Administrator/.qgis2/python/plugins\\LecoS', 'C:/Users/Administrator/.qgis2/python/plugins\\processing', 'C:/OSGEO4~1/apps/qgis-rel-dev/./python', u'C:/Users/Administrator/.qgis2/python', u'C:/Users/Administrator/.qgis2/python/plugins', 'C:/OSGEO4~1/apps/qgis-rel-dev/./python/plugins', 'C:\\OSGEO4~1\\apps\\Python27\\lib\\site-packages\\matplotlib-1.3.1-py2.7-win-amd64.egg', 'C:\\OSGEO4~1\\apps\\Python27\\lib\\site-packages\\nose-1.3.3-py2.7.egg', 'C:\\OSGEO4~1\\apps\\Python27\\lib\\site-packages\\tornado-4.0.1-py2.7-win-amd64.egg', 'C:\\OSGEO4~1\\apps\\Python27\\lib\\site-packages\\backports.ssl_match_hostname-3.4.0.2-py2.7.egg', 'C:\\OSGEO4~1\\apps\\Python27\\lib\\site-packages\\certifi-14.05.14-py2.7.egg', 'c:\\osgeo4~1\\apps\\python27\\lib\\site-packages\\python_dateutil-2.1-py2.7.egg', 'c:\\osgeo4~1\\apps\\python27\\lib\\site-packages\\six-1.3.0-py2.7.egg', 'C:\\OSGEO4~1\\bin\\python27.zip', 'C:\\OSGEO4~1\\apps\\Python27\\DLLs', 'C:\\OSGEO4~1\\apps\\Python27\\lib', 'C:\\OSGEO4~1\\apps\\Python27\\lib\\plat-win', 'C:\\OSGEO4~1\\apps\\Python27\\lib\\lib-tk', 'C:\\OSGEO4~1\\bin', 'C:\\OSGEO4~1\\apps\\Python27', 'c:\\osgeo4~1\\apps\\python27\\lib\\site-packages\\jinja2-2.7.2-py2.7.egg', 'c:\\osgeo4~1\\apps\\python27\\lib\\site-packages\\markupsafe-0.23-py2.7-win-amd64.egg', 'c:\\osgeo4~1\\apps\\python27\\lib\\site-packages\\pytz-2012j-py2.7.egg', 'c:\\osgeo4~1\\apps\\python27\\lib\\site-packages\\shapely-1.2.18-py2.7-win-amd64.egg', 'c:\\osgeo4~1\\apps\\python27\\lib\\site-packages\\xlrd-0.9.2-py2.7.egg', 'c:\\osgeo4~1\\apps\\python27\\lib\\site-packages\\xlwt-0.7.5-py2.7.egg', 'C:\\OSGEO4~1\\apps\\Python27\\lib\\site-packages', 'C:\\OSGEO4~1\\apps\\Python27\\lib\\site-packages\\PIL', 'C:\\OSGEO4~1\\apps\\Python27\\lib\\site-packages\\win32', 'C:\\OSGEO4~1\\apps\\Python27\\lib\\site-packages\\win32\\lib', 'C:\\OSGEO4~1\\apps\\Python27\\lib\\site-packages\\Pythonwin', 'C:\\OSGEO4~1\\apps\\Python27\\lib\\site-packages\\wx-2.8-msw-unicode', u'C:/Users/Administrator/.qgis2//python', 'C:\\Users\\Administrator\\.qgis2\\python\\plugins\\DigitizingTools\\tools', 'C:\\Users\\Administrator\\.qgis2\\python\\plugins\\mmqgis/forms', 'C:\\Users\\Administrator\\.qgis2\\python\\plugins\\QuickMultiAttributeEdit/forms', 'C:\\Users\\Administrator\\.qgis2\\python\\plugins\\StreamFeatureExtractor\\third_party', 'C:\\OSGEO4~1\\apps\\qgis-rel-dev\\python\\plugins\\fTools\\tools', 'C:\\OSGEO4~1\\apps\\Python27\\lib\\site-packages\\IPython\\extensions']
elpaso commented 9 years ago

Sorry: I'm not on windows and I cannot help much. I would try to run the IPython imports from a standard python console outside QGIS and see if that works. If it doesn't, it means that the issue is not QGIS specific and you can probably ask on the IPython mailing list.

spaceof7 commented 9 years ago

The imports work from the standard python console and ipython and the ipython qtconsole run properly outside of QGIS. Ill see if I can figure it out, though I have it working on Ubuntu which i use more often anyways. Thanks.

anitagraser commented 9 years ago

Just ran into the same issue. I also made sure all dependencies listed on https://ipython.org/ipython-doc/dev/install/install.html are installed but no luck.

elpaso commented 9 years ago

File "C:\OSGEO4~1\apps\Python27\lib\ctypesinit.py", line 365, in init self._handle = _dlopen(self._name, mode) WindowsError: [Error 126] The specified module could not be found

I would try inspect self._name , it seems an import error in ctypes. Googling for the error message finds some answers on SO.

spaceof7 commented 9 years ago

I did some digging on this but am in over my head and I will just stick to using it on Ubuntu. If anyone is trying to solve this I found what appears to be the same problem with vim-ipython here: https://github.com/ivanov/vim-ipython/issues/95

the problems seems to be with dependencies for zmq. I followed some of the suggestions in the thread and ended up experimenting with editing the manifest but I ran into some new errors.

fejikso commented 9 years ago

I experienced the same problem. Windows 64, QGIS 2.8.1 Wien. IPython works well by itself, but not when I use the plugin.

elpaso commented 9 years ago

I'm sorry I can't help, if anybody knows how this plugin can be successfully installed on windows please let me know and I'll add the informations to the plugin "about" or "description" and to the error message.

fejikso commented 9 years ago

I spent some time trying to fix this (unsuccessfully), but I think I found that the problem is caused by the fact that many enviroment variables change and the python path is changes when QGIS is loaded. It fails to load the zmq module, even if it is installed in the QGIS Python installation. When I import zmq from OSGeo4W Shell, it works fine, but within QGIS Python Shell it does not. It gives the same problem as your plugin.

Many searches point to a similar problem (like in http://gis.stackexchange.com/questions/27476/why-cant-i-import-my-script-from-the-python-console)

If I have time, I'll try to continue digging into this, but I'm swamped with work at the moment... If anybody else finds a solution, please share!

elpaso commented 9 years ago

@fejikso yes, I wear my gloves and tried on a win 7 vm I keep for browser testings and I came up to the same conclusion. Even if I install IPython (after Anaconda) and it runs fine in the command prompt, it fails to load libsodium with ctypes in zmq init.py (line 25). Loading libsodium from the python interpreter with the very same instructions and paths works just fine. It might worth to check differences in sys.path (I added Anaconda site-packages in QGIS startup.py but this just solves the first step). QGIS probably uses a custom sys.path environment.

vesnikos commented 9 years ago

Hmm the same error pops with 32bit version of OSGeo4W as well.

andrewgrapentin commented 8 years ago

Open your "Visual Studio 2008 Command Prompt" and run the commands in the link.

https://github.com/zeromq/pyzmq/issues/161#issuecomment-66776901