# Strange sudo / bash / python error

## urcindalo

Thanks for reading this.

I have this really strange problem when launching an application with sudo:

```
$ sudo pymol

/usr/bin/python2.6: can't open file '/__init__.py': [Errno 2] No such file or directory
```

However, the pymol command is a shell script:

```
$ cat /usr/bin/pymol

#!/bin/sh

python -O ${PYMOL_PATH}/__init__.py $*
```

The PYMOL_PATH value is defined for both my regular user and root, and the file __init__.py exists within the path:

```
$ echo $PYMOL_PATH

/usr/lib64/python2.6/site-packages/pymol

...

# echo $PYMOL_PATH

/usr/lib64/python2.6/site-packages/pymol

# ls -la /usr/lib64/python2.6/site-packages/pymol/__init__.py

-rw-r--r-- 1 root root 20178 jul  7  2009 /usr/lib64/python2.6/site-packages/pymol/__init__.py
```

However, I can launch the program being root, or my regular user, just by issuing the command specified in the launching script:

```
# python -O ${PYMOL_PATH}/__init__.py $*

 PyMOL(TM) Molecular Graphics System, Version 1.2r2pre.

 Copyright (C) 2009 by DeLano Scientific LLC.

 All Rights Reserved.

    Created by Warren L. DeLano, Ph.D.

    PyMOL is user-supported open-source software.  Although some versions

    are freely available, PyMOL is not in the public domain.

    If PyMOL is helpful in your work or study, then please volunteer

    support for our ongoing efforts to create open and affordable scientific

    software by purchasing a PyMOL Maintenance and/or Support subscription.

    More information can be found at "http://www.pymol.org".

    Enter "help" for a list of commands.

    Enter "help <command-name>" for information on a specific command.

 Hit ESC anytime to toggle between text and graphics.

 OpenGL graphics engine:

  GL_VENDOR: ATI Technologies Inc.

  GL_RENDERER: ATI Mobility Radeon HD 4500 Series

  GL_VERSION: 2.1.9116

 Note: Radeon HD cards tend not to run PyMOL well.

 Use nVidia or Intel instead, if OpenGL glitches occur.

 Attempting to compensate for known issues...

 Detected 2 CPU cores.  Enabled multithreaded rendering.

Created temporary files directory:  /root/.ADplugin

 PyMOL: normal program termination.
```

Finally, to make things even more strange, I run another box, the configuration of which is the same, where I can normally launch pymol with root priviledges through sudo.

Any help is greatly appreciated. I'm really clueless here.

Thanks.

----------

## bombcar

sudo isn't loading environmental variables for some reason, or isn't passing them on.

----------

## urcindalo

 *bombcar wrote:*   

> sudo isn't loading environmental variables for some reason, or isn't passing them on.

 

Thanks for your help. Yes, I think so, but I can't guess why  :Confused: 

Does anybody know what could I check out?

----------

## Axilatis

i know it's very very old topic but if someone's got the same problem, the solution is to :

```
etc-update
```

then

```
env-update && source /etc/profile
```

after emerging pymol  :Very Happy: 

----------

## Hu

No, that is not the relevant solution here.  In the problem described by the OP, the environment variables were correctly set in the profile and in the running shell.  However, sudo scrubbed the environment.

----------

## AngelKnight

 *urcindalo wrote:*   

>  *bombcar wrote:*   sudo isn't loading environmental variables for some reason, or isn't passing them on. 
> 
> Thanks for your help. Yes, I think so, but I can't guess why 
> 
> Does anybody know what could I check out?

 

"sudo -L" and/or check on the sudoers file and see what the precise configuration is w.r.t. how sudo handles environment variables.

As a dumb test, have a test script with just:

```
#!/bin/sh

echo "PYMOL_PATH is $PYMOL_PATH"

```

Set it executable somewhere and run via sudo.  This is a quicker way to test if sudo's stripping your environment.

----------

