1

I tried to get PYTHONPATH in the python process (ex. the console or some packages ) of Sublime Text 2 running "os.environ.get('pythonpath')", but it's empty. It seems not to import only PYTHONPATH from system environment variables. Other variables were imported.

If editing "Python.sublime-build", variables was not imported.

Can I get PYTHONPATH in the process?

Yosuke Asano
  • 13
  • 1
  • 3
  • Where do you need to change the PYTHONPATH? Is this in a module you are writing for Sublime, or a test that you are running using the build command from sublime? – dbn Jan 21 '13 at 17:43
  • It's in a module. When a subprocess is created in a module (ex. Terminal Package), I expect PYTHONPATH imported, but not. – Yosuke Asano Jan 22 '13 at 09:54
  • Ahh, ok. In that case, the build system is not used. You should check out ["Directing Packages to the correct python installation"](http://stackoverflow.com/q/10712390/1309332) or ["Change python interpreter"](http://stackoverflow.com/q/11313131/1309332) – dbn Jan 22 '13 at 21:03
  • I have read both, then it seems that there is no way to set PYTHONPATH to all modules in Sublime Text2 and I should set each. Thank you for your comments! – Yosuke Asano Jan 24 '13 at 04:12

1 Answers1

0

Use the env option in your custom Python build system (documented here). Basically, you'll want something like this:

"env": {
        "PYTHONPATH":"/my/custom/modules"
       }

Make sure if you are overriding the default Python build rule that you do it in the User folder so that your customization will persist through upgrades.

dbn
  • 13,144
  • 3
  • 60
  • 86
  • Basically the same as [this question/answer](http://stackoverflow.com/a/11120411/1309332) – dbn Jan 18 '13 at 20:12
  • What I concerned is not build system, but python package system. Even if putting 'env' to Python.sublime-build, it's no available from package process? – Yosuke Asano Jan 21 '13 at 02:43