Use carefully, there are security issues with sudo and variables.
man sudoers I found that you should use
Defaults env_keep += "PYTHONPATH OTHERVARIABLE YETANOTHER"
sudo does preserves some variables.
sudo -i is more like logging in as root and then running the command.
Both may be inconvenient, the former for
sudo nano myfile leaves root-owned files inside your home and the latter for
sudo -i nano myfile will try to open /root/myfile.
sudo printenv PATH
and see what it gives. Here it gives
for example. Now run
sudo visudo and add the line
replacing by what you found just before. Append a new path to it if you need.
sudo LD_LIBRARY_PATH=/usr/lib/path/to/a/safe/library your command
Linux distributions take a lot of
PATH, and you really should be careful before playing with it.
Be specially careful about adding paths like "
/home/username, it is unsecure.
One of the dangers of adding paths is that it opens for the possibility of files on these paths getting executed by
root, opening a windows in the system security that may be exploited by malicious software. There may be other dangers. Just make sure you know what you are doing. Bypassing
sudo security measures may render your Solaris as safe as Windows XP.