Sublime Forum

Python path and $PYTHONPATH

#1

When I write plugins I often load Python modules. Because Sublime Text doesn’t pick up the usual environment I use sys.path.append. I think there must be a neater solution than this. Is there a way to have Sublime Text pick up the contents of my ordinary $PYTHONPATH for the purpose of plug-ins?

(I’m using Sublime Text 3 on OSX Yosemite, if that’s relevant.)

0 Likes

#2

I’m going to guess that you are setting your environment variables like PYTHONPATH in your shell (like in .profile or .bashrc). If you launch sublime from the Terminal (using subl), then it should pick up your environment. If you are launching it from Spotlight or the Dock, then it won’t. For that to work reliably, you need to set the environment variables with launchctl. Do a google search for “yosemite environment variables”. It looks like things may have changed in Yosemite (it looks like editing launchd.conf no longer works), and I’m not currently running Yosemite on my laptop so I can’t test it.

0 Likes

#3

Thanks. Yes, I set my $PYTHONPATH in .bashrc. My brief search suggested that this is a mess in Yosemite. In the end I decided to move all my sys.append calls to a library that all my plug-ins load. That keeps things neater and meets my needs so far.

0 Likes