Komodo Edit Changes Python sys.path If you "Show in Explorer"

Question:

I am using Komodo Edit, a code editor.

When I right click on projects and click "Show in Explorer", it will pop up a box just like Windows Explorer at the directory my project is. This is very convenient.

However, I noticed an insidious side effect. When you try to run a python file with this window that looks exactly like Windows Explorer, you will find out that it completely messes up sys.path in Python to use its own directory.

Is there any way to avoid this?

import sys
sys.path

C:Windowssystem32python26.zip
C:Program FilesActiveState Komodo Edit 5libpythonDLLs
C:Program FilesActiveState Komodo Edit 5libpythonlib
C:Program FilesActiveState Komodo Edit 5libpythonlibplat-win
C:Program FilesActiveState Komodo Edit 5libpythonliblib-tk
C:Python26
C:Program FilesActiveState Komodo Edit 5libpython
C:Program FilesActiveState Komodo Edit 5libpythonlibsite-packages
C:Program FilesActiveState Komodo Edit 5libpythonlibsite-packageswin32
C:Program FilesActiveState Komodo Edit 5libpythonlibsite-packageswin32lib
C:Program FilesActiveState Komodo Edit 5libpythonlibsite-packagesPythonwin
Asked By: Unknown

||

Answers:

Oups! I’ve the same behavior on my Vista machine. I didn’t see any settings for that feature and I think that this is a Komodo bug.

I though about a workaround: create a new command in the toolbox with “explorer %D” as command line. But it has the same problem 🙁

Update: The workaround works if you put %D for StartIn. See the capture:

alt text http://img10.imageshack.us/img10/2972/komodoshowinexplorer.jpg

Answered By: luc

What should your sys.path be instead? It looks like Python is already on the path, but maybe you need other libraries there, too.

If you’re missing some key directories, use sys.path.append in one of your Python modules. If you need to move the directory of the Python interpreter (which may be necessary in order to get relative pathnames to work), use os.chdir as well.

Edit: It strikes me that you probably already know about those functions and that the problem lies elsewhere.

Answered By: Nikhil

This is indeed a problem in Komodo. It actually stems from the Explorer window spawned by Komodo having the PYTHONHOME environment variable set to include Komodo’s path, since the child process inherits the parent’s environment. I noticed this by opening a Command Prompt window through an Explorer spawned by Komodo. If you look at the output from set, it contains (among other things) the following:

PYTHONHOME=C:Program FilesActiveState Komodo Edit 5libpython
_KOMODO_HOSTUSERDATADIR=C:UsersDevAppDataRoamingActiveStateKomodoEdit5.1host-host
_KOMODO_VERUSERDATADIR=C:UsersDevAppDataRoamingActiveStateKomodoEdit5.1
_XRE_USERAPPDATADIR=C:UsersDevAppDataRoamingActiveStateKomodoEdit5.1host-hostXRE

I reported this bug here at the ActiveState bug tracker.

Answered By: AKX

I’d recommend going into Komodo Edit’s Preferences >> Environment, and changing PYTHONHOME back to the original python install (e.g. c:python27)

Answered By: Ryan Ginstrom