Komodo using python from QGis distribution

Hi there,

I’m using geographical information system QGIS which is delivered with an python environment. This python environment has some extensions embedded, which cannot currently be installed on windows systems otherwise (at least I failed several times …).

Therefore I want to use the QGIS python for my development.

Trying to use the delivered python interpreter within KomodoIDE (by setting the path to python.exe within preferences->python->default python interpreter), Komodo says:

Invalid python interpreter . The chosen Python has version, which will not work as python interpreter

Checking the version of the delivered python, it’s version 2.7.5

Does Komodo not support debugging 2.7.5 - or what is wrong here?

Any hints appreciated - TIA


Hi, when checking a given Python executable for validity, Komodo runs that exe with the following arguments:

python.exe -c "import sys; sys.stdout.write(sys.version)"

From Komodo’s error message, it is not getting a recognized version string. This may happen with custom Python builds. In that case, please post the version string, and we’ll go from there.

You shouldn’t be doing this. That’s a custom Python 2.7 install with custom packages that will differ from a standard Python install. Also if were install additional packages uses that interpreter it could break Komodo completely. If you need a Python interpreter ActiveState distributes mutliple versions for all platforms, including Windows:

It is odd that it says it’s not a proper Python interpreter according to Komodo though. I’m interested to see what Mitchell’s instructions produce.

  • Carey

I have to do this, as this distribution includes some packages which aren’t available through ActiveState Python (especially pyspatialite) I already tried to install this package manually as well (using ActiveState Python) - but without success.
Also as QGIS relies on its own python and is not able to use another python (as far as I have seen) and I don’t plan to use python for anything else yet (as I’m mostly a Perl-man), I don’t want two python distributions installed.
It’s a pity - so I have to use anything like pdb (or any other debugger) … :unamused:


V:\QGIS 2.18>python.exe -c “import sys; sys.stdout.write(sys.version)”
results in
2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]

Sorry @hoppfrosch1, I was confused by your wording. It sounded like you configured Komodo to use Komodo’s Python (Komodo Install/lib/python). I now see you meant the QGIS Python. My bad, you should definitely be able to do this.

@mitchell would be the pro here, sorry to have interjected.

  • Carey

Ok give this a try, this would set the pref for your Python interpreter without validating the input. Keep in mind that you are exploring new territories here though.

require("ko/prefs").setString("pythonDefaultInterpreter", "C:\path\to\python.exe")

You can run that in the console widget (bottom pane).

Opened a bug here:

That looks like a proper version string. Is there anything in your Help > Troubleshooting > View Log File related to the error? I think the error is occurring before the version check. (Thus Komodo is rejecting the executable for some reason.)

Sorry fot the late response - I was Out of Office the last days…

Here is the entry of Help>Troubleshooting>View Log File concerning this problem:

[2017-01-12 06:40:29,312] [ERROR] koAppInfo: Failed to check version of executable V:\QGIS 2.18\bin\python.exe
Traceback (most recent call last):
  File "D:\Usr\programme\ActiveState Komodo IDE 10 nightly\lib\mozilla\components\koAppInfo.py", line 190, in _isValidExecutable
    isvalid = self._isValidExecutableVersion(exe)
  File "D:\Usr\programme\ActiveState Komodo IDE 10 nightly\lib\mozilla\components\koAppInfo.py", line 162, in _isValidExecutableVersion
    versionParts = invocationutils.split_short_ver(ver, intify=True)
  File "D:\Usr\programme\ActiveState Komodo IDE 10 nightly\lib\mozilla\python\komodo\invocationutils.py", line 94, in split_short_ver
    raise ValueError("%r is not a valid short version string" % ver_str)
ValueError: '' is not a valid short version string

@careyh: No problem - as I’m not a native english speaker, my wording might be confusing anytime … :smirk:

@nathanr: Using the given command in the console widget solves my pain … Thanks!

Let’s see, when the next problems occur! :smirk:

There’s a slight discrepancy I’d like to clear up. In the version string you gave, you executed “python.exe” from the “V:\QGIS 2.18” directory, but your “python.exe” is located in “V:\QGIS 2.18\bin”. Please run python.exe -c "import sys; sys.stdout.write(sys.version)" from “V:\QGIS 2.18\bin”. That way we can make sure that you are running the correct python.exe, and not another one in your %PATH%.

@mitchell : The result is:

V:\QGIS 2.18>python.exe -c "import sys; sys.stdout.write(sys.version)"
2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]

This has to be, since you have to start a separate shell if you want to use python from QGIS. The shell startup-script sets all the correct pathes.

NathanR’s solution with manually setting PythonInterpreter via Komodo console works - as far as I have verified. I only added a few pathes to “Additional Python Import directories” within the Komodo preferences

So you’re saying you started a QGIS shell, which dumped you to “V:\QGIS 2.18”, set up all your paths correctly, and running “python.exe” cannot be any other exe than the QGIS exe in “V:\QGIS 2.18\bin”?

Yes - that’s what I’m saying.

My path env within the running shell:

Path=V:\QGIS 2.18\apps\Python27\Scripts;V:\QGIS 2.18\bin;C:\Windows\system32;C:\Windows;C:\Windows\WBem

Thanks. I cannot think of any reason why that version string should cause a failure. Other than the workaround Nathan gave you, I do not know how to solve this issue.