2

I am trying to develop a plugin for QGIS but I am having trouble setting up my IDE with the required python executable so I can get a console working for logging output while developing it. When I deliberately enter some messed up text in the script, and then try to run the plugin in QGIS, I can see an error in the stacktrace that I would assume indicates where the executable is:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 333, in startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "/home/isaac/.qgis2/python/plugins/MakeOSMRoutableNetwork/__init__.py", line 34, in classFactory
    from .make_osm_routable_network import MakeOSMRoutableNetwork
  File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 607, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/isaac/.qgis2/python/plugins/MakeOSMRoutableNetwork/make_osm_routable_network.py", line 214
    self.dlg.postgis_connection_listView.addItem(k)weqweqfasfsdf
                                                               ^
SyntaxError: invalid syntax

So it seems like my python exectuable is in /usr/lib/python2.7. Alright, fair enough. But when I navigate to this directory and list the contents, I don't see any python executable. Shouldn't there be one in here? I am using Ubuntu 16.04.

closed as off-topic by user2856, lynxlynxlynx, PolyGeo Aug 30 '17 at 22:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • You can open a python window in QGIS (plugins::Python Console) and get the path from there, print '\n'.join(sys.path)... other suggestions don't seem to work for me, sys.executable returns QGIS, which/where python returns a syntax error. Another interesting method is to import in the python window (from qgis import core) and then type core and hit enter, it will bring up a module description which includes path. These both work on Windows and may or may not work for Linux; of course which/where python may actually do something on Linux. – Michael Stimson Aug 29 '17 at 20:58
  • /usr/lib/python2.7 is not your executable nor where it should be. It's where the various modules get installed. – lynxlynxlynx Aug 30 '17 at 22:14
0

/usr/bin/python2.7 is your python.

Actually, you can use any of /usr/bin/python, /usr/bin/python2 or /usr/bin/python2.7

i.e. (On 17.04):

$ which python
/usr/bin/python
$ file `which python`
/usr/bin/python: symbolic link to python2.7
$ which python2
/usr/bin/python2
$ file `which python2`
/usr/bin/python2: symbolic link to python2.7
$ which python2.7
/usr/bin/python2.7
$ file `which python2.7`
/usr/bin/python2.7: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=b0407272b6bf54e757c18df5a69a7b6468c08b64, stripped

Why isn't your python in /usr/lib? According to the Filesystem Hierarchy Standard which defines the layout of Linux filesystems, /usr/bin is the primary directory for executable commands for all users and/usr/lib includes object files and libraries for the commands in /usr/bin.

Not the answer you're looking for? Browse other questions tagged or ask your own question.