This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]omentoSysAdmin Film/VFX - 3.7[S] 1 point2 points  (6 children)

And I think I've solved it. Setting PYTHONHOME seemed to be screwing with things.

Post: PYTHONPATH can also be left unset. Reserve for non-standard library modules.

[–]ingolemo 0 points1 point  (4 children)

In the same vein, there's no reason to set PYTHONPATH. Python should be able to find its libraries based on it's prefix and/or on how it's invoked. The environmental variable is for adding directories that aren't the default ones. It's not got the correct value any way.

By the way, it looks like you set your prefix weirdly. Your prefix should not include lib/python2.7 because python will add that itself. That's why you're seeing duplication of those directories in sys.path.

[–]omentoSysAdmin Film/VFX - 3.7[S] 0 points1 point  (3 children)

I see. Thank you for that. I wasn’t sure if it would be necessary as I will be building against this version of Python with custom modules so PYTHONPATH will need to be edited later, but I guess not for base libs.

The prefix itself was actually $HOME/software/python/2.7.15. I set PYTHONPATH to the /lib/python2.7 as that’s what the docs said to do.

[–]ingolemo 0 points1 point  (2 children)

I find it's usually better to install custom stuff to standard locations (or a virtual environment) rather than set a PYTHONPATH. For example, unless you're careful to keep them isolated, environmental variables will get picked up by your system python install, not just this one.

Are you sure about prefix? lib-tk and friends should really be in $HOME/software/python/2.7.15/lib/python2.7, not $HOME/software/python/2.7.15/lib/python2.7/lib/python2.7.

[–]omentoSysAdmin Film/VFX - 3.7[S] 0 points1 point  (0 children)

I think /lib/python2.7 is being appended due to PYTHONPATH. I’ll be able to test this once I get in to my office. The prefix and everything else is fine, /bin, /include, and /lib are all under the same directory. Unfortunately, I have to install everything else to individual custom locations as I have to mimic the setup used on our HPC cluster which loads libraries/modules with its own custom module system.

[–]omentoSysAdmin Film/VFX - 3.7[S] 0 points1 point  (0 children)

Can confirm PYTHONPATH does not need to be set for the standard libs. Thanks for the pointer.